Implementing Finalize and Dispose to Clean Up Unmanaged Resources

by Damiaan Peeters 2. March 2008 12:04

I found some design patterns about implementing Dispose & Destructors in C#.

Class instances often encapsulate control over resources that are not managed by the runtime, such as window handles (HWND), database connections, and so on. Therefore, you should provide both an explicit and an implicit way to free those resources. Provide implicit control by implementing the protected Finalize on an object (destructor syntax in C# and C++). The garbage collector calls this method at some point after there are no longer any valid references to the object.

Implementing Finalize and Dispose to Clean Up Unmanaged Resources

blog comments powered by Disqus

Who.I.am

Certified Umbraco Master, Part of Umbraco Certified partner comm-it, .Net and Azure developer, seo lover. Magician in my spare time.

Month List