If we not suppress finalize method in dispose what will happen?
Answer Posted / 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 View All Answers
What type of filter does outputcacheattribute class represents?
What is the role of the jit compiler in .net framework?
Why is the .net framework 3.0 a major version number of the .net framework if it uses the .net framework 2.0 runtime and compiler?
What are non action methods in mvc?
explain lazy loading, eager loading, and explicit loading?
What is ViewData and TempData in ASP.Net MVC?
Can we add constraints to the route? If yes, explain how we can do it?
How does the .net framework 3.0 relate to the .net framework 2.0?
What is entity sql? : Entity framework
What is the significance of nonactionattribute?
What are the components required to create a route in ASP.Net MVC?
Is .net framework 4.8 the last version?
List out few different return types of a controller action method?
Can I use razor code in javascript in asp.net mvc?
What is meant by viewdata?