Hi All,
I am trying to write code to sync between processes. Here is the piece of code:
setSignal(); // signal me (WaitHandle) first
if (!WaitHandle.WaitAll(mWaitHandles, timeout_ms, true)) // mWaitHandles is an array of named event handles
{
mLog.WriteLine("While wait for sync, it's timed out."); // better not reach here, so timeout_ms should be big
}
resetSignal(); // reset WaitHandle
My problem is that because setSignal() and WaitHandle.WaitAll() is not atomic, other processes could have reset Signal before I enter WaitAll(), then I have a deadlock or timeout. So I need a SignalAndWait() similar method SignalAndWaitAll(). Is there such construct? If not, can I create one?
Thanks for your consideration.