Here is the code from MSDN . I don’t understand why the work is not just done in the regular Dispose () method. What is the purpose of using the Dispose (bool) method? Who could call Dispose (false) here?
public void Dispose()
{
Dispose(true);
GC.SuppressFinalize(this);
}
protected virtual void Dispose(bool disposing)
{
if (!_disposed)
{
if (disposing) {
if (_resource != null)
_resource.Dispose();
Console.WriteLine("Object disposed.");
}
_resource = null;
_disposed = true;
}
}
source
share