Does anyone know how .NET handles a timeout on a call to Semaphore.WaitOne(timeout)?
I'd expect a TimeoutException, but the MSDN documentation doesn't list this in the list of expected exceptions, and I can't seem to find it documented anywhere.
The method will return false if it times out, and true if it returns a signal:
if (mySemaphore.WaitOne(1000))
{
    // signal received
}
else
{
    // wait timed out
}
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With