Categories:
.NET (357)
C (330)
C++ (183)
CSS (84)
DBA (2)
General (7)
HTML (4)
Java (574)
JavaScript (106)
JSP (66)
Oracle (114)
Perl (46)
Perl (1)
PHP (1)
PL/SQL (1)
RSS (51)
Software QA (13)
SQL Server (1)
Windows (1)
XHTML (173)
Other Resources:
How do I force the Dispose method to be called automatically , as clients can forget to call Dispose method
How do I force the Dispose method to be called automatically, as clients can forget to call Dispose method?
✍: Guest
Call the Dispose method in Finalize method and in Dispose method suppress the finalize method using GC.SuppressFinalize. Below is the sample code of the pattern. This is the best way we do clean our unallocated resources and yes 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
2007-10-23, 8147👍, 0💬
Popular Posts:
How To Recover a Dropped Index? - Oracle DBA FAQ - Managing Oracle Table Indexes If you have the rec...
What’ is the sequence in which ASP.NET events are processed ? Following is the sequence in which the...
How To Control Horizontal Alignment? - XHTML 1.0 Tutorials - Understanding Tables and Table Cells By...
How To Avoid the Undefined Index Error? - PHP Script Tips - Processing Web Forms If you don't want y...
.NET INTERVIEW QUESTIONS - Did VB6 support multi-threading ? While VB6 supports multiple single-thre...