示例#1
0
        public virtual void Dispose(bool disposing)
        {
            if (Data != IntPtr.Zero)
            {
                if (GCHandle.IsAllocated)
                {
                    GCHandle.Free();
                }
                Data = IntPtr.Zero;
            }

            if (Handle != IntPtr.Zero)
            {
                UV.Free(Handle);
                Handle = IntPtr.Zero;
            }
        }
示例#2
0
        public void Cleanup(IntPtr nativeHandle, Action callback)
        {
            // Remove handle
            if (NativeHandle != IntPtr.Zero)
            {
                Loop.handles.Remove(nativeHandle);

                UV.Free(nativeHandle);

                NativeHandle = IntPtr.Zero;

                Closed?.Invoke();

                if (callback != null)
                {
                    callback();
                }

                if (GCHandle.IsAllocated)
                {
                    GCHandle.Free();
                }
            }
        }