Skip to content

Commit

Permalink
Rethrow with InvalidOperationException when called from WaitHandle
Browse files Browse the repository at this point in the history
I think it would make much more sense to always throw SemaphoreFullException instead of sometimes throwing InvalidOperationException saying the semaphore is full, but this preserves the old behavior.
  • Loading branch information
CoffeeFlux committed Mar 12, 2021
1 parent def05ab commit 891987b
Showing 1 changed file with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,14 @@ public static int SignalAndWait(
throw new ThreadInterruptedException();
}

waitableObjectToSignal.Signal(1);
try
{
waitableObjectToSignal.Signal(1);
}
catch (SemaphoreFullException ex)
{
throw new InvalidOperationException(SR.Threading_WaitHandleTooManyPosts, ex);
}
waitCalled = true;
return waitableObjectToWaitOn.Wait_Locked(waitInfo, timeoutMilliseconds, interruptible, prioritize);
}
Expand Down

0 comments on commit 891987b

Please sign in to comment.