I need to synchronize two applications by using a named event. But neither AutoResetEvent nor ManualResetEvent contains constructor with a name for event (only initial state). I can open existing named event through static method OpenExisting in AutoResetEvent or ManualResetEvent class, but can't create It! I don't want to use native WinAPI CreateEvent function for It, unless I know precisely of not existing of other ways.
AutoResetEvent is used for send signals between two threads. Both threads share the same AutoResetEvent object. Thread can enter into a wait state by calling WaitOne() method of AutoResetEvent object. When second thread calls the Set() method it unblocks the waiting thread.
Calling Set signals AutoResetEvent to release a waiting thread. AutoResetEvent remains signaled until a single waiting thread is released, and then automatically returns to the non-signaled state. If no threads are waiting, the state remains signaled indefinitely.
An AutoResetEvent resets when the code passes through event. WaitOne() , but a ManualResetEvent does not.
Set to signal that the waiting threads can proceed. All waiting threads are released. Once it has been signaled, ManualResetEvent remains signaled until it is manually reset by calling the Reset() method. That is, calls to WaitOne return immediately.
I found a solution by myself. That is:
EventWaitHandle handle =
new EventWaitHandle(false, EventResetMode.ManualReset, "testRemoteServer");
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With