To clarify your general question about when to do Dispose and Finalize:
If you have a field in your class, this IntPtr(or some other unmanaged resource, but IntPtris the most common), and your classes are responsible for cleaning this resource, then you need to implement a finalizer. In this finalizer, you must release any resource you point to IntPtr. If you do not have IntPtr, then the class you are holding must handle its own finalization and will implement it IDisposeable(see next part)
, IDisposable, , IDisposable dispose Dispose() .
. , , , .
, , ...
, . , null .
public sealed class Example : IDisposable
{
public EventHandler MyEvent;
public void Dispose()
{
MyEvent = null;
}
}
EDIT: , Hans Passant : , , . SafeHandle . , IDisposable, .Dispose().