S
Stephen
In Visual Studio's help for GC.SuppressFinalize, it gives the following
example:
public void Dispose()
{
Dispose(true);
// This object will be cleaned up by the Dispose method.
// Therefore, you should call GC.SupressFinalize to
// take this object off the finalization queue
// and prevent finalization code for this object
// from executing a second time.
GC.SuppressFinalize(this);
}
All other examples I've found on the web also include the
GC.SuppressFinalize method at the end of the Dispose method. I would have
thought that as soon as I know that the Dispose has been called (ie the
start of the method), I would want to remove the object from the
finalization queue. Is there a reason why GC.SuppressFinalize isn't the
first call in the Dispose method?
example:
public void Dispose()
{
Dispose(true);
// This object will be cleaned up by the Dispose method.
// Therefore, you should call GC.SupressFinalize to
// take this object off the finalization queue
// and prevent finalization code for this object
// from executing a second time.
GC.SuppressFinalize(this);
}
All other examples I've found on the web also include the
GC.SuppressFinalize method at the end of the Dispose method. I would have
thought that as soon as I know that the Dispose has been called (ie the
start of the method), I would want to remove the object from the
finalization queue. Is there a reason why GC.SuppressFinalize isn't the
first call in the Dispose method?