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
What are the different types of triggers in SQl There are 2 types of triggers in the SQL server 2000 :- 1) INSTEAD OF triggers: The INSTEAD OF triggers fire in place of


What is RAID and how does it work? The Redundant Array of Independent Disks (RAID) is a term used for describing the technique of improving data availability through the use of

How do I write common code for different dot net framework data providers?

I need C# Programmer Project Description: To help in the production of a C# module to provide a web service. We are based in Littlehampton, West Sussex. Skills required ar

Project Description: We are a small development house in Singapore, and have a project which is 90 percent complete; thud our previous developer could not finish due to other co

Custom authentication: If we don't need ASP.NET to perform any authentication, we can set the authentication mode to none. The reason behind this decision could be: We don't

Finding Largest Array Element - C# Program I am unable to make out the Largest Array Element in C# language. Can anyone suggest me any example for this.

What are major difference between classic ADO and ADO.NET? Following are some major differences among both In ADO we have recordset and in ADO.NET we have dataset. In rec

help me to prepare the above charts for my online vegetable selling project