Woody said:
1. Dispose Method what it does ?
It is a member of the IDisposable interface and it used to free
unmanaged resources (windows handles, files, ...)
A. who its call / when it calls ?
It is called explicitly by the users of the class that implements it. A
call to the Dispose method it is propagated to all the parent types of
this class.
B. Is it fire automatically ?
It can also called by the runtime inside a finalizer method
c. When dispose method is call what it does ?
It is implementation dependent. If you develop a class that uses
unmanaged resources (eg, handles), you should free that resources
inside the IDisposable.Dispose method (eg. calling CloseHandle()).
D. Release a Object from memory or release refrence from memory ?
Releases an (unmanaged) object from memory at specific time
E. If it release object from memory then what GC does ?
GC frees unreferenced managed objects. GC has no knowledge of
unmanaged resources
2. Which class can have dispose method ?
class which is member of IDispose Inteface
Classes that create unmanaged resources should implement IDisposable
interface.
Great,
Thanks
Woody said:
1. Dispose Method what it does ?
It is a member of the IDisposable interface and it used to free
unmanaged resources (windows handles, files, ...)
Here what do u mean of unmanage resources ?
bcoz if we are using C# in that case we are implicitly using managecode
,I think in that case we wont required dispose method bcoz GC will take care
of these things.
Yes we can also use unmanage code in C# , but for that we need to
explicitly compile these class as in unsafe mode , I think in that case
only dispose method will work ?
A. who its call / when it calls ?
It is called explicitly by the users of the class that implements it. A
call to the Dispose method it is propagated to all the parent types of
this class.
c. When dispose method is call what it does ?
It is implementation dependent. If you develop a class that uses
unmanaged resources (eg, handles), you should free that resources
inside the IDisposable.Dispose method (eg. calling CloseHandle()).
In (A .) You are saying that its called explicitly ? if it call explicitly
how we can call
how we can call finalize method ?
Is there any finalize method , I think finalize is part of
gc.suppressfinalize().
What happend when we call object=null ?
1.1 It will also release resources ?
1.2 It will called finalize / dispose method ?
2.1 What is diffrence between finalize and dispose method ?
2.2 who will call to whome ?
2.3 finalize call dispose / dispose call finalize ?
2.4 how it will called (finalize/dispose) ?
Thanks in advance