views:

434

answers:

1

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.

Thanks in advance!

+2  A: 

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
}
Fredrik Mörk
That did it, thanks!
James B