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 poco proxy? : Entity framework
What is razor code?
What filters are executed in the end?
What is entity client data provider? : Entity framework
how do you mark a property as required? For example, for a project, the name is a required field.
What is representational state transfer (rest) mean?
what is entity framework advantage?
Name a few different return types of a controller action method?
Can a view be shared across multiple controllers? If yes, how we can do that?
mention what is code first approach and model first approach in entity framework?
what is explicit loading?
Can you use Razor code in Javascript in ASP.Net MVC?
Can I use razor code in javascript in asp.net mvc?
How does the .net framework 3.0 relate to windows vista?
What is the need of Action Filters in ASP.Net MVC