问题描述
大家好,
程序运行到这段代码时出现错误:
I got an error when program ran into this piece of code :
while(!want_shutdown){
dwWaitResult = WaitForMultipleObjects(NUM_EVENTS,hEvents,-----程序已在此处退出!!!
FALSE,INFINITE); ;
/*了解我们为什么退货*/
如果(WaitSucceeded(dwWaitResult,NUM_EVENTS)){
/*
*返回是由于其中一个事件
*收到信号
*/
开关(WaitSucceededIndex(dwWaitResult)){
案例RELOAD_EVENT:
want_reload = ISC_TRUE;
休息;
案例SHUTDOWN_EVENT:
want_shutdown = ISC_TRUE;
休息;
}
}
if(want_reload){
want_reload = ISC_FALSE;
返回(ISC_R_RELOAD);
}
if(want_shutdown&&被阻止)
exit(-1);
}
while (!want_shutdown) {
dwWaitResult = WaitForMultipleObjects(NUM_EVENTS, hEvents, ----- Program has exited here !!!
FALSE, INFINITE);
/* See why we returned */
if (WaitSucceeded(dwWaitResult, NUM_EVENTS)) {
/*
* The return was due to one of the events
* being signaled
*/
switch (WaitSucceededIndex(dwWaitResult)) {
case RELOAD_EVENT:
want_reload = ISC_TRUE;
break;
case SHUTDOWN_EVENT:
want_shutdown = ISC_TRUE;
break;
}
}
if (want_reload) {
want_reload = ISC_FALSE;
return (ISC_R_RELOAD);
}
if (want_shutdown && blocked)
exit(-1);
}
请让我知道我遇到的问题以及解决方案.
Please let me know the problem i got, and solutions for that.
非常感谢
谢谢
Khoa Tran
Khoa Tran
推荐答案
确保在调用此函数之前,不要关闭传入WaitForMultipleObjects(在此示例中为hEvent)的句柄.根据MSDN,如果关闭,我们可能会有不确定的行为. 句柄必须具有SYNCHRONIZE访问权限.
Make sure the handle which passed in WaitForMultipleObjects ( hEvents in this example), should not close before this function call. As per MSDN, if it close, we might have undefined behavior. The handles must have the SYNCHRONIZE access right.
这篇关于在WaitForMultipleObjects函数处退出程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!