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 is entity graph? : Entity framework
Is .net core replacing .net framework?
What is mapping in entity framework? : Entity framework
How does the .net framework 3.0 relate to windows vista?
Which are the important namespaces used in ASP.Net MVC?
What is the difference between ViewData, ViewBag and TempData?
List out few different return types of a controller action method?
What is Differnce between html.action and ajax.action?
What are the components of the .net framework.
mention what is code first approach and model first approach in entity framework?
Why we need a separate mobile project template, while we can render our web application in mobile ?
What is edm (entity data model)? : Entity framework
Name a few different return types of a controller action method?
How we can handle the exception at controller level in ASP.Net MVC?
How does .net framework works?