See Also: CriticalHandle Members
The System.Runtime.InteropServices.CriticalHandle class is similar to the System.Runtime.InteropServices.SafeHandle class, except that System.Runtime.InteropServices.SafeHandle implements reference counting. You can use System.Runtime.InteropServices.CriticalHandle instead of System.Runtime.InteropServices.SafeHandle to address performance considerations when you can provide the necessary synchronization more efficiently yourself.
Because the System.Runtime.InteropServices.CriticalHandle class does not perform reference counting, it does not provide protection from handle recycling security attacks. Because the reference counting algorithm implicitly serializes operations, a certain amount of thread safety is also lost. If you call the IDisposable.Dispose or SafeHandle.Close method while an operation that is using the handle is outstanding on another thread, or if you call IDisposable.Dispose or SafeHandle.Close from two threads at the same time, the results are non-deterministic. The System.Runtime.InteropServices.CriticalHandle class still provides the guaranteed critical finalization provided by the System.Runtime.ConstrainedExecution.CriticalFinalizerObject class.