예제 #1
0
        /// <summary>
        /// Frees the pinned handle and releases IPinnable.
        /// </summary>
        public void Dispose()
        {
            if (_pinnable != null)
            {
                _pinnable.Unpin();
                _pinnable = null;
            }

            _pointer = null;
        }
예제 #2
0
        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();
        }
예제 #3
0
        /// <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;
        }