void FreeHandle(ref IntPtr handle) { if (handle == IntPtr.Zero) return; GCHandle handleCallback = GCHandle.FromIntPtr(handle); handleCallback.Free(); handle = IntPtr.Zero; }