In an almost 10 year old system, I've implemented several IDisposable
implementations. Back in the old days, when I was younger and still foolish, the trend was to implement a finalizer as well:
class MyClass: IDisposable
{
public void Dispose() { Dispose(true); }
~MyClass { Dispose(false); }
private void Dispose(bool bDisposing)
{
... dipose ...
if(bDisposing)
GC.SupressFinalize(this);
}
}
Finally, after almost a decade, this bit us - the Dispose method threw an exception while being called from the finalizer, and the process died unexpectedly and without warning.
I want to remove all the finalizers, and keep just the Dispose
method that will dispose of the resources. Is there any reason to keep the finalizers around? None of the objects use unmanaged resources, so I'm pretty sure I won't get resource leaks. Right?