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; } }
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(); } } }