public bool TrySignalToSatisfyWait(WaitedListNode registeredListNode, bool isAbandonedMutex) { s_lock.VerifyIsLocked(); Debug.Assert(_thread != Thread.CurrentThread); Debug.Assert(registeredListNode != null); Debug.Assert(registeredListNode.WaitInfo == this); Debug.Assert(registeredListNode.WaitedObjectIndex >= 0); Debug.Assert(registeredListNode.WaitedObjectIndex < _waitedCount); Debug.Assert(_waitedCount > (_isWaitForAll ? 1 : 0)); int signaledWaitedObjectIndex = registeredListNode.WaitedObjectIndex; bool isWaitForAll = _isWaitForAll; bool wouldAnyMutexReacquireCountOverflow = false; if (isWaitForAll) { // Determine if all waits would be satisfied if (!WaitableObject.WouldWaitForAllBeSatisfiedOrAborted( _thread, _waitedObjects, _waitedCount, signaledWaitedObjectIndex, ref wouldAnyMutexReacquireCountOverflow, ref isAbandonedMutex)) { return(false); } } // The wait would be satisfied. Before making changes to satisfy the wait, acquire the monitor and verify that // the thread can accept a signal. _waitMonitor.Acquire(); if (!IsWaiting) { _waitMonitor.Release(); return(false); } if (isWaitForAll && !wouldAnyMutexReacquireCountOverflow) { // All waits would be satisfied, accept the signals WaitableObject.SatisfyWaitForAll(this, _waitedObjects, _waitedCount, signaledWaitedObjectIndex); } UnregisterWait(); Debug.Assert(_waitedObjectIndexThatSatisfiedWait < 0); if (wouldAnyMutexReacquireCountOverflow) { _waitSignalState = WaitSignalState.NotWaiting_SignaledToAbortWaitDueToMaximumMutexReacquireCount; } else { _waitedObjectIndexThatSatisfiedWait = signaledWaitedObjectIndex; _waitSignalState = isAbandonedMutex ? WaitSignalState.NotWaiting_SignaledToSatisfyWaitWithAbandonedMutex : WaitSignalState.NotWaiting_SignaledToSatisfyWait; } _waitMonitor.Signal_Release(); return(!wouldAnyMutexReacquireCountOverflow); }