private static SafeWaitHandle NewHandle(WaitableObject waitableObject) { IntPtr handle = HandleManager.NewHandle(waitableObject); SafeWaitHandle?safeWaitHandle = null; try { safeWaitHandle = new SafeWaitHandle(handle, ownsHandle: true); return(safeWaitHandle); } finally { if (safeWaitHandle == null) { HandleManager.DeleteHandle(handle); } } }
public static void DeleteHandle(IntPtr handle) { HandleManager.DeleteHandle(handle); }