System.Runtime.InteropServi ...


.NET Framework Class Library
CriticalHandle Class

Represents a wrapper class for handle resources.

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

Visual Basic (Declaration)
<SecurityPermissionAttribute(SecurityAction.LinkDemand, UnmanagedCode := True)> _
<SecurityPermissionAttribute(SecurityAction.InheritanceDemand, UnmanagedCode := True)> _
Public MustInherit Class CriticalHandle _
    Inherits CriticalFinalizerObject _
    Implements IDisposable
Visual Basic (Usage)
Dim instance As CriticalHandle
C#
[SecurityPermissionAttribute(SecurityAction.LinkDemand, UnmanagedCode = true)]
[SecurityPermissionAttribute(SecurityAction.InheritanceDemand, UnmanagedCode = true)]
public abstract class CriticalHandle : CriticalFinalizerObject, 
    IDisposable
Visual C++
[SecurityPermissionAttribute(SecurityAction::LinkDemand, UnmanagedCode = true)]
[SecurityPermissionAttribute(SecurityAction::InheritanceDemand, UnmanagedCode = true)]
public ref class CriticalHandle abstract : public CriticalFinalizerObject, 
    IDisposable
JScript
public abstract class CriticalHandle extends CriticalFinalizerObject implements IDisposable
Remarks

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.

.NET Framework Security

Inheritance Hierarchy

System..::.Object
  System.Runtime.ConstrainedExecution..::.CriticalFinalizerObject
    System.Runtime.InteropServices..::.CriticalHandle
      Microsoft.Win32.SafeHandles..::.CriticalHandleMinusOneIsInvalid
      Microsoft.Win32.SafeHandles..::.CriticalHandleZeroOrMinusOneIsInvalid
Thread Safety

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

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

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
Version Information

.NET Framework

Supported in: 3.5, 3.0, 2.0
See Also

Reference

Tags :


Page view tracker