Example #1
0
        private int ReleaseCore(int releaseCount)
        {
            // The field value is modifiable via the public <see cref="WaitHandle.SafeWaitHandle"/> property, save it locally
            // to ensure that one instance is used in all places in this method
            SafeWaitHandle waitHandle = SafeWaitHandle;

            if (waitHandle.IsInvalid)
            {
                ThrowInvalidHandleException();
            }

            waitHandle.DangerousAddRef();
            try
            {
                return(WaitSubsystem.ReleaseSemaphore(waitHandle.DangerousGetHandle(), releaseCount));
            }
            finally
            {
                waitHandle.DangerousRelease();
            }
        }
Example #2
0
 private void ReleaseCore(int count)
 {
     WaitSubsystem.ReleaseSemaphore(_semaphore, count);
 }
Example #3
0
 private static int ReleaseCore(IntPtr handle, int releaseCount)
 {
     return(WaitSubsystem.ReleaseSemaphore(handle, releaseCount));
 }