Disposable
public class DisposableExample : IDisposable { private bool disposed = false; protected void Dispose(bool disposing) { if (!disposed) { if (disposing) { //Dispose managed resources } //Dispose umanaged resources disposed = true; } } public void Dispose() { Dispose(true); GC.SuppressFinalize(this);//It means suppress Destructor, if Dispose is called , Destructor will not be called } ~DisposableExample() { Dispose(false); } }