CriticalHandle Class
Collapse the table of content
Expand the table of content

CriticalHandle Class

Represents a wrapper class for handle resources.

Namespace: System.Runtime.InteropServices
Assembly: mscorlib (in mscorlib.dll)

Public MustInherit Class CriticalHandle
	Inherits CriticalFinalizerObject
	Implements IDisposable
Dim instance As CriticalHandle

public abstract class CriticalHandle extends CriticalFinalizerObject implements IDisposable
public abstract class CriticalHandle extends CriticalFinalizerObject implements IDisposable
Not applicable.

The CriticalHandle class is similar to the SafeHandle class, except that SafeHandle implements reference counting. You can use CriticalHandle instead of SafeHandle to address performance considerations when you can provide the necessary synchronization more efficiently yourself.

Because the 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 Close method while an operation that is using the handle is outstanding on another thread, or if you call IDisposable.Dispose or Close from two threads at the same time, the results are non-deterministic. The CriticalHandle class still provides the guaranteed critical finalization provided by the CriticalFinalizerObject class.

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Windows 98, Windows Server 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0

Community Additions

© 2016 Microsoft