What is the best way to reset a semaphore that have threads waiting on it. Right now all I can think of is just doing a while loop and releasing the semaphore until a semaphore full exception occurs. I’m not sure what is the best practice.
semaphore.Close();
semaphore = new Semaphore(0,1);
Or
while(true)
{
try
{
semaphore.Release();
}
catch
{
break;
}
}
semaphore = new Semaphore(0,1);
If you want to do that, are you sure you want a
Semaphoreto start with? Perhaps aManualResetEventwould be more appropriate?