I saw this thread here but didnt get any answer to my thoughts.
for my understanding :
the reclaim of native reources will Always occur !
- when
GCoccurs ( after the second round) - calling dispose
- using
Using - crash of the program
- graceful terminate program
so why do i need to inherit from CriticalFinalizerObject ?
I don’t see any situation where the reources Won’t be reclaimed….
what am i missing ?
The
CriticalFinalizerObjectclass does add some reliability to the Dispose/Finalize process. Like preventingThread.Abort()et al.The main reason to use
Safehandle : CriticalFinalizerObjectis that it relieves you from dealing with the unmanaged resource pattern. A SafeHandle turns an unmanaged resource into a managed resource, see Joe Duffy.I don’t think that as an Application programmer you will ever have to derive a class from CriticalFinalizerObject, but when you have to deal with a ‘handle’ you should use
SafeHandle.