O'Reilly logo

Microsoft® Visual Basic® 2010 Developer’s Handbook by Klaus Löffelmann and Sarika Calla Purohit

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Dispose

The IDisposable interface provides an implementation rule that helps you implement a method that you can call from your code (unlike Finalize) to dispose of an object. If you implement this interface in your classes via Implements, you must also add a Dispose method, which is then responsible for all the necessary clean-up. You basically try to simulate the functionality of a real destructor in other OOP languages, which is typically called automatically, without your help. Calling Dispose is therefore a compromise that you make—it’s the tradeoff for having the advantages of the GC.

Note

Use Using as a structure block to achieve an implicit Dispose for the used object when the program leaves the scope of the structure block.

The clean-up ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required