某个事件初始化之后,如何判断它是处于SetEvent还是ResetEvent?
另外,我在多线程时,在一个线程里,无限期等待多个Event,
发现两个事件应该SetEvent过的了,但那个线程无输出,
//以下是一些主要代码
//串口事件线程
unsigned int __stdcall ThreadComEvent(void* pv)
{
dw = WaitCommEvent(hCom, &dwEvent, &o);
if (dwEvent == (EV_RXCHAR | EV_RX80FULL))
{
debug_out(("ThreadComEvent >> dwEvent:%d\n", dwEvent));
ComEventLocker.lock();
SetEvent(hComReadEvent);
ComEventLocker.unlock();
}
}
//读串口线程
unsigned int __stdcall ThreadComRead(void* pv)
{
HANDLE handles[2];
handles[0] = hComOpenEvent;
handles[1] = hComReadEvent;
:WaitForMultipleObjects(_countof(handles), handles, true, INFINITE))
debug_out(("[读线程] >> WaitForMultipleObjects 有结果 \n"));
}
hComOpenEvent当串口成功打开后SetEvent(hComOpenEvent);
hComReadEvent当串口收到消息后SetEvent(hComReadEvent);
上述代码没有出现我预期的结果,
不知道是不是线程问题