Skip to content

Instantly share code, notes, and snippets.

@joshgo
Created May 17, 2013 02:38
Show Gist options
  • Save joshgo/5596569 to your computer and use it in GitHub Desktop.
Save joshgo/5596569 to your computer and use it in GitHub Desktop.
Disposable Template - Courtesy of http://blog.phatboyg.com/
public class DisposableClass : IDisposable
{
bool _disposed;
public void Dispose()
{
Dispose(true);
GC.SuppressFinalize(this);
}
~DisposableClass()
{
Dispose(false);
}
protected virtual void Dispose(bool disposing)
{
if (_disposed)
return;
if (disposing)
{
// free other managed objects that implement
// IDisposable only
}
// release any unmanaged objects
// set thick object references to null
_disposed = true;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment