Skip to content

Instantly share code, notes, and snippets.

@blachniet
Last active December 21, 2015 04:29
Show Gist options
  • Select an option

  • Save blachniet/6250136 to your computer and use it in GitHub Desktop.

Select an option

Save blachniet/6250136 to your computer and use it in GitHub Desktop.
The dispose pattern.
#region Dispose Pattern
private bool _disposed;
public void Dispose()
{
Dispose(true);
GC.SuppressFinalize(this);
}
protected virtual void Dispose(bool disposing)
{
if (!_disposed)
{
if (disposing)
{
if (_resource != null)
_resource.Dispose();
}
_resource = null;
_disposed = true;
}
}
#endregion
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment