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


Please Help Members By Posting Answers For Below Questions

What is entity graph? : Entity framework

532


Is .net core replacing .net framework?

473


What is mapping in entity framework? : Entity framework

518


How does the .net framework 3.0 relate to windows vista?

565


Which are the important namespaces used in ASP.Net MVC?

598






What is the difference between ViewData, ViewBag and TempData?

637


List out few different return types of a controller action method?

611


What is Differnce between html.action and ajax.action?

566


What are the components of the .net framework.

575


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

631


Why we need a separate mobile project template, while we can render our web application in mobile ?

590


What is edm (entity data model)? : Entity framework

548


Name a few different return types of a controller action method?

539


How we can handle the exception at controller level in ASP.Net MVC?

571


How does .net framework works?

563