If we not suppress finalize method in dispose what will happen?

Answers were Sorted based on User's Feedback



If we not suppress finalize method in dispose what will happen?..

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

If we not suppress finalize method in dispose what will happen?..

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

Post New Answer

More Dot Net Framework Interview Questions

What does assert() method do?

1 Answers   MCN Solutions, Siebel Systems,


Is mvc 4 supporting windows azure sdk (software development kit) ?

0 Answers  


How to set the debug mode

1 Answers   4Cplus,


What is Global Assembly Cache (GAC) and what is the purpose of it?

2 Answers  


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 ?

2 Answers  






What is the common property in .net?

1 Answers   Nth Solution,


When was the first version of .NET released

1 Answers  


What are Model Binders in ASP.Net MVC?

0 Answers  


What are multicast delegates ? give me an example

1 Answers  


mention what is code first approach and model first approach in entity framework?

0 Answers   Microsoft,


What is the purpose of a web form?

0 Answers  


What are the contents of assembly?

2 Answers  


Categories