Export (0) Print
Expand All

SafeHandle Constructor

Initializes a new instance of the SafeHandle class with the specified invalid handle value.

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

protected SafeHandle(
	IntPtr invalidHandleValue,
	bool ownsHandle
)

Parameters

invalidHandleValue
Type: System.IntPtr

The value of an invalid handle (usually 0 or -1). Your implementation of IsInvalid should return true for this value.

ownsHandle
Type: System.Boolean

true to reliably let SafeHandle release the handle during the finalization phase; otherwise, false (not recommended).

ExceptionCondition
TypeLoadException

The derived class resides in an assembly without unmanaged code access permission.

If the ownsHandle parameter is false, ReleaseHandle is never called; thus, it is not recommended to use this parameter value as your code may leak resources.

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.

.NET Framework

Supported in: 3.5, 3.0, 2.0

Community Additions

ADD
Show:
© 2015 Microsoft