Reputation: 6343
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.
Upvotes: 12
Views: 7290
Reputation: 158309
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
}
Upvotes: 13