Leslie Sanford wrote:
So what you're saying is that the garbage collector will call Dispose() in any case?
It will if a Dispose() call is placed in the Finalizer/destructor of the class (~DatabaseConnection in my case..) -- and that is the case if you follow the NET documentation pattern for implementing IDisposable:
public class SomeClass : IDisposable
{
~SomeClass()
{
Dispose(false);
}
...
.. so if you've followed that pattern, forgetting some Dispose() (or using-clauses equivalently) calls would not be that dramatic for your application. BUT: I'm still not 100% clear on the low-level semantics of GC/Dispose in .NET. Below is a link to a long technical discussion I'm reading up on just to be sure what I've said is correct. Otherwise, I have quite a lot of things to do next week at work ;) : http://www.thescripts.com/forum/thread214497.html A link within that discussion points to a "morale" of why/how Dispose came about, really interesting read. Apparently it's written by one of the original .NET designers: http://discuss.develop.com/archives/wa.exe?A2=ind0010A&L=DOTNET&P=R28572 -- modified at 15:26 Friday 10th August, 2007