/// <summary> /// Frees the pinned handle and releases IPinnable. /// </summary> public void Dispose() { if (_pinnable != null) { _pinnable.Unpin(); _pinnable = null; } _pointer = null; }
public static unsafe void PinnablePointer() { Pointer <int> ptr = stackalloc int[1]; ptr.Value = 42; IPinnable pinnable = ptr; using var handle = pinnable.Pin(0); Equal(42, ((int *)handle.Pointer)[0]); pinnable.Unpin(); }
/// <summary> /// Frees the pinned handle and releases IPinnable. /// </summary> public void Dispose() { if (_handle.IsAllocated) { _handle.Free(); } if (_pinnable != null) { _pinnable.Unpin(); _pinnable = null; } _pointer = null; }