/// <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.UnsafeQueueWaitCompletion(new CompleteWaitThreadPoolWorkItem(registeredHandle, timedOut)); }