แก้ไข

แชร์ผ่าน


SafeHandle(IntPtr, Boolean) Constructor

Definition

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

protected:
 SafeHandle(IntPtr invalidHandleValue, bool ownsHandle);
protected SafeHandle (IntPtr invalidHandleValue, bool ownsHandle);
new System.Runtime.InteropServices.SafeHandle : nativeint * bool -> System.Runtime.InteropServices.SafeHandle
Protected Sub New (invalidHandleValue As IntPtr, ownsHandle As Boolean)

Parameters

invalidHandleValue
IntPtr

nativeint

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

ownsHandle
Boolean

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

Exceptions

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

Remarks

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.

Applies to