Method WithNativePointer
- Namespace
- Ubiquity.NET.InteropHelpers
- Assembly
- Ubiquity.NET.InteropHelpers.dll
WithNativePointer<THandle, TRetVal>(THandle[], ReturningOp<TRetVal>)
Marshals an array SafeHandle to a native pointer (as an array of nint)
public static TRetVal WithNativePointer<THandle, TRetVal>(this THandle[] managedArray, RefHandleMarshaller.ReturningOp<TRetVal> op) where THandle : SafeHandle
Parameters
managedArray
THandle[]Managed array of handles to marshal (by reference)
op
RefHandleMarshaller.ReturningOp<TRetVal>Operation to perform with the native array.
Returns
- TRetVal
Value returned from
op
Type Parameters
THandle
SafeHandle type to marshal
TRetVal
Return type of the operation
Remarks
A native nint holding array is allocated, then the managed array's handle values are
copied to it (Without any AddRefs etc... the managed array OWNS the handles) before
pinning the memory for the native handles and calling op
WithNativePointer<THandle>(THandle[], VoidOp)
Marshals an array SafeHandle to a native pointer (as an array of nint)
public static void WithNativePointer<THandle>(this THandle[] managedArray, RefHandleMarshaller.VoidOp op) where THandle : SafeHandle
Parameters
managedArray
THandle[]Managed array of handles to marshal (by reference)
op
RefHandleMarshaller.VoidOpOperation to perform with the native array.
Type Parameters
THandle
SafeHandle type to marshal
Remarks
A native nint holding array is allocated, then the managed array's handle values are
copied to it (Without any AddRefs etc... the managed array OWNS the handles) before
pinning the memory for the native handles and calling op