Reputation: 37
is there an equivalent in C# of the event objects created in c++ using the win api function "CreateEvent".
Upvotes: 2
Views: 1922
Reputation: 8071
There are various synchronization primitives available in C#/.NET, events are directly available as ManualResetEvent
or AutoResetEvent
, or, more generally, they are wrapped in EventWaitHandle
.
Upvotes: 1
Reputation: 13535
Yes it is called EventWaitHandle. To create a named auto reset event which can be opened by other processes you can use this:
bool bCreated;
var ev = new EventWaitHandle(true, EventResetMode.AutoReset, @"Global\myGlobalEvent", out bCreated);
If you want a simple Manual/AutoResetEvent you can use the classes AutoResetEvent and ManualResetEvent respectively. WaitHandle exposes the full feature set such as creating a named event.
Yours, Alois Kraus
Upvotes: 3