See sample code from MSDN: ( http://msdn.microsoft.com/en-us/library/b1yfkh5e (v = VS.100) .aspx )
public class Base: IDisposable
{
private bool disposed = false;
public void Dispose()
{
Dispose(true);
GC.SuppressFinalize(this);
}
protected virtual void Dispose(bool disposing)
{
if (!disposed)
{
if (disposing)
{
}
disposed = true;
}
}
~Base()
{
Dispose (false);
}
}
In the implementation of Dispose (), it calls GC.SupressFinalize (); but provides a destructor to complete the object.
What is the point of providing a destructor implementation when calling GC.SuppressFinalize ()?
Confuse a little, what are the intentions?
source
share