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
Why to use Html.Partial in ASP.Net MVC?
Explain test driven development (tdd) ?
what is use of entity container?
explain why t4 entity is important in entity framework?
Explain the new features 3.5 framework against with the tool?
What is .net framework & its benefits?
How we can call a javascript function on the change of a dropdown list in mvc?
What are actions in mvc?
Does windows 10 need .net framework?
What are the levels at which filters can be applied in an asp.net mvc application?
What is Differnce between html.action and ajax.action?
Why to use '{resource}.axd/{*pathInfo}' in routing in ASP.Net MVC?
What are the versions of .net framework?
Which version of .net framework is installed?
Which is the root namespace for fundamental types in .net framework?