예제 #1
0
        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);
                }
            }
        }
예제 #2
0
        private static SafeWaitHandle NewHandle(WaitableObject waitableObject)
        {
            var safeWaitHandle = new SafeWaitHandle();

            IntPtr handle = IntPtr.Zero;

            try
            {
                handle = HandleManager.NewHandle(waitableObject);
            }
            finally
            {
                if (handle == IntPtr.Zero)
                {
                    waitableObject.OnDeleteHandle();
                }
            }

            Marshal.InitHandle(safeWaitHandle, handle);
            return(safeWaitHandle);
        }