15,471
社区成员
发帖
与我相关
我的任务
分享
DWORD WINAPI ThreadProc(LPVOID lpParameter) { DWORD dwRet = 0; int nIndex = 0; while(1) { dwRet = WaitForMultipleObjects(nCount,pHandles,false,INFINITE); switch(dwRet) { case WAIT_TIMEOUT: break; case WAIT_FAILED: return 1; default: { nIndex = dwRet - WAIT_OBJECT_0; ProcessHanlde(nIndex++); //同时检测其他的事件 while(nIndex < nCount) //nCount事件对象总数 { dwRet = WaitForMultipleObjects(nCount - nIndex,&pHandles[nIndex],false,0); switch(dwRet) { case WAIT_TIMEOUT: nIndex = nCount; //退出检测,因为没有被触发的对象了. break; case WAIT_FAILED: return 1; default: { nIndex = nIndex + dwRet - WAIT_OBJECT_0; ProcessHanlde(nIndex++); } break } } } break; } } return 0; }