New Dispose Guidelines

Joe Duffy has posted the revised Dispose, Finalization, and Resource Management Design Guideline. It’s a great (and long) read. Check it out!

The Truth About GCHandles

I’ve heard several people asking why GCHandle doesn’t implement IDisposable, considering it wraps an unmanaged resource (a handle) and needs to be explicitly freed (using GCHandle.Free()). Before I explain the reason, I want to give a little background on GCHandles and their dangers. What’s a GCHandle? A GCHandle is a struct that contains a handle…


Dispose Dos and Don’ts

Due to the positive response on my previous entry on Dispose, I thought I’d write another, this time on what one should and shouldn’t do with a Dispose method. Dispose should contain code to release any unmanaged resources associated with the object’s instance. For example, any handles should be released, database connections closed, etc. This…


Demystifying Dispose

One commonly misunderstood feature is the relationship between disposable objects (Objects that implement the IDisposable interface) and the GC.  I know there are a lot of online resources about patterns and best practices but there is still a lot of confusion.  I remember going to a Dev Lab to answer some questions by Whidbey early…