If we not suppress finalize method in dispose what will happen?
Answers were Sorted based on User's Feedback
Answer / answerme
If we do not suppress finalize method in dispose, the
finalise method will be called twice by the garbage
collector. Once the method that is called by the developer
and once when the GC runs for checking the object that are
out of scope. This hampers the performance and is heavy on
performance.
Is This Answer Correct ? | 2 Yes | 0 No |
Answer / seema dalal
Dispose methods can be called automatically, if client
forget to call it.
for this ,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.
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
Is This Answer Correct ? | 0 Yes | 4 No |
What does assert() method do?
1 Answers MCN Solutions, Siebel Systems,
Is mvc 4 supporting windows azure sdk (software development kit) ?
How to set the debug mode
What is Global Assembly Cache (GAC) and what is the purpose of it?
I am going for H1B visa interview, I am not having bank statement ,is it neccesary for stamping process? how to handle the,consulate people without that statement ?
What is the common property in .net?
When was the first version of .NET released
What are Model Binders in ASP.Net MVC?
What are multicast delegates ? give me an example
mention what is code first approach and model first approach in entity framework?
What is the purpose of a web form?
What are the contents of assembly?