How do i force the dispose method to be called automatically, DOT NET Programming

How do I force the Dispose method to be called automatically, as clients can forget to call Dispose method?

To Call the Dispose method in the Finalize method and in the Dispose method suppress the finalize method using GC.SuppressFinalize. The sample code of the pattern is shown below. This is the best way we do clean our unallocated resources and yet not to forget we do not get the hit of running the Garbage collector twice.

Note:- It will suppress the finalize method thus avoiding the two trip. Public Class ClsTesting

Implements IDisposable

Public Overloads Sub Dispose()Implements IDisposable.Dispose

' write ytour clean up code here

GC.SuppressFinalize(Me) End Sub

Protected Overrides Sub Finalize() Dispose()

End Sub

End Class

Posted Date: 9/22/2012 3:23:45 AM | Location : United States







Related Discussions:- How do i force the dispose method to be called automatically, Assignment Help, Ask Question on How do i force the dispose method to be called automatically, Get Answer, Expert's Help, How do i force the dispose method to be called automatically Discussions

Write discussion on How do i force the dispose method to be called automatically
Your posts are moderated
Related Questions
Describe the XmlWriter class. The XmlWriter class is used to write XML to a stream, a file, or a Textwriter object. This class works in a forward-only, non-cached manner. You c

What are major difference between classic ADO and ADO.NET ? Some major differences between the classic ADO & ADO.NET are as follows: 1) As in the classic ADO we had server a

having trouble programming

What are the different Visual Basic features that support LINQ? Visual Basic includes the following features that support LINQ: Anonymous types - Enables you to make a ne

Project Description: Legacy ASP.NET application for managing tasks for a private client needs a complete re-write. The application has approximately 2500 lines of code, combi

Automate installation setup Project Description: The steps are: Clicking four times accept and the setup goes to tray, I do not want to block the mouse or the keyboard. Sk

How to Creating a Key Pair ? You can create a key pair using the Strong Name tool (Sn.exe). Key pair files usually have an .snk extension. To create a key pair At the comman

.NET aplication with vBulletin paid subscribtion Project Description: I have an application in .net it's a simple client i have sheltered with net seal license system for aut

The Performance of the viewstate varies depending on the type of server control to which it is applied. The Text Box, Label,   RadioButton,CheckBox, and HyperLink are server contro

What are Value types and Reference types The Value types directly contain their data which are either allocated on the stack or allocated in-  Line in a  structure. The Refe