SafeHandle(IntPtr, Boolean) Constructor
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
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
Feedback
https://aka.ms/ContentUserFeedback.
Coming soon: Throughout 2024 we will be phasing out GitHub Issues as the feedback mechanism for content and replacing it with a new feedback system. For more information see:Submit and view feedback for