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
Prepare .NET TWAIN application to control digital imaging sensor Project Description: We are seeking somebody to create a .NET TWAIN application which will activate a digital

Project Description: Digital invy - inventory management Main Features User friendly windows based software Multi Branch Multi company facility Multi user Integra


Want Microsoft CRM Dynamics CRM 2011 or 2013 programmer Project Description: Need to do customizations in CRM itself and integrate CRM 2011 with SAP Business One and HTML web

Urgently seeking a senior Extjs developer with strong NET developing skill Project Description: Urgently seeking a senior Extjs developer with strong NET developing skill

What is a class? A class describes all the attributes of objects, as well as the methods that execute the behaviour of member objects. It is a comprehensive data type, which sh

What are design patterns? The Design patterns are recurring solution to the recurring problems in the software architecture. There are 3 basic classification of patterns Behavi

how can we use entity framework in ASP.Net MVC

What is an IL? Intermediate Language is also called as MSIL (Microsoft Intermediate Language) or CIL (Common Intermediate Language). All .NET source code is compiled to IL. IL

What are shared (VB.NET)/Static(C#) variables? Shared/Static classes are used when a class gives functionality which is not specific to any instance. In brief if you want an ob