/// <summary> /// Queue a call to <see cref="CompleteWait(object)"/> on the ThreadPool. /// </summary> /// <param name="registeredHandle">The handle that completed.</param> /// <param name="timedOut">Whether or not the wait timed out.</param> private void QueueWaitCompletion(RegisteredWaitHandle registeredHandle, bool timedOut) { registeredHandle.RequestCallback(); // If the handle is a repeating handle, set up the next call. Otherwise, remove it from the wait thread. if (registeredHandle.Repeating) { registeredHandle.RestartTimeout(Environment.TickCount); } else { UnregisterWait(registeredHandle, blocking: false); // We shouldn't block the wait thread on the unregistration. } ThreadPool.QueueUserWorkItem(CompleteWait, new CompletedWaitHandle(registeredHandle, timedOut)); }
/// <summary> /// Queue a call to complete the wait on the ThreadPool. /// </summary> /// <param name="registeredHandle">The handle that completed.</param> /// <param name="timedOut">Whether or not the wait timed out.</param> private void QueueWaitCompletion(RegisteredWaitHandle registeredHandle, bool timedOut) { registeredHandle.RequestCallback(); // If the handle is a repeating handle, set up the next call. Otherwise, remove it from the wait thread. if (registeredHandle.Repeating) { registeredHandle.RestartTimeout(); } else { UnregisterWait(registeredHandle, blocking: false); // We shouldn't block the wait thread on the unregistration. } ThreadPool.UnsafeQueueHighPriorityWorkItemInternal( new CompleteWaitThreadPoolWorkItem(registeredHandle, timedOut)); }