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 is entity framework firstordefault?

0 Answers  


what happened when type url in address bar and press enter?

5 Answers   IBM, Wipro,


What is the difference between structures and enumeration ?

1 Answers  


What is Attribute Routing in ASP.Net MVC?

0 Answers  


what is the use of final method

3 Answers   TCS,






What is the difference between using system.net and system.net.sockets?

1 Answers  


Will the name change be reflected in any of the existing .net framework 2.0 apis, assemblies, or namespaces?

0 Answers  


I can't be bothered with all this CAS stuff. Can I turn it off

1 Answers  


Speaking of Boolean data types, what's different between C# and C/C++ ?

1 Answers  


How do I define my own code group

1 Answers  


What are the components required to create a route in mvc?

0 Answers  


Hello frnds, Actually i am plannig to put fake Xperince letter is it good or not, and please suggest me from where we take it.

1 Answers  


Categories