Semaphore timeout mechanism in C #

Does anyone know how .NET handles a timeout when calling Semaphore.WaitOne(timeout) ?

I would expect a TimeoutException , but the MSDN documentation does not list this in the list of expected exceptions, and I cannot find it anywhere in the documents.

Thanks in advance!

+7
c # timeout semaphore
source share
1 answer

The method will return false if it expires, and true if it returns a signal:

 if (mySemaphore.WaitOne(1000)) { // signal received } else { // wait timed out } 
+7
source share

All Articles