加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > Windows > 正文

windows – WaitForMultipleObjects()是否重置所有自动重置事件

发布时间:2020-12-14 02:27:11 所属栏目:Windows 来源:网络整理
导读:我有一个等待几个自动重置事件的事件循环. 这些事件都使用CreateEvent(NULL,false,NULL)初始化为数组eventHandles_. while (true){ DWORD waitResult = WaitForMultipleObjects(3,eventHandles_,INFINITE); switch (waitResult) { case WAIT_OBJECT_0 + 0: /
我有一个等待几个自动重置事件的事件循环.
这些事件都使用CreateEvent(NULL,false,NULL)初始化为数组eventHandles_.

while (true)
{
    DWORD waitResult = WaitForMultipleObjects(3,eventHandles_,INFINITE);
    switch (waitResult)
    {
    case WAIT_OBJECT_0 + 0:
        //handle event...

    case WAIT_OBJECT_0 + 1:
        //handle event...

    case WAIT_OBJECT_0 + 2:
        //handle event...
    }
}

我的问题:如果事件1和2同时发生,循环将处理WAIT_OBJECT_0 1因为它是第一个.但是当循环再次出现时,事件2是否仍会发出信号?还是会自动重置?

解决方法

“……修改只发生在信号状态导致函数返回的对象或对象中……”

http://msdn.microsoft.com/en-us/library/windows/desktop/ms687025(v=vs.85).aspx

从一个Raymond Chen口:

If waiting for one event,then only that event is modified. If waiting for all events,then all are modified. That’s what the documentation means by “object or objects”. Singular if wait-any,plural if wait-all.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读