简体   繁体   中英

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

在C#中,使用win api函数“ CreateEvent”在c ++中创建的事件对象是否等效。

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

C#/。NET中提供了各种同步原语,事件可以直接以ManualResetEventAutoResetEvent ,或者更一般而言,将它们包装在EventWaitHandle

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM