x3r5d4
x3r5d4

Reputation: 37

C# equivalent of Event Objects in c++ , winapi

is there an equivalent in C# of the event objects created in c++ using the win api function "CreateEvent".

Upvotes: 2

Views: 1922

Answers (2)

Mormegil
Mormegil

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

Alois Kraus
Alois Kraus

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

Related Questions