一个MsgWaitForMultipleObjects函数的有关问题!解决五体投地的感谢
一个MsgWaitForMultipleObjects函数的问题!解决五体投地的感谢!
DWORD dRet=0;
MSG msg;
//int nExitThreadCount=0,totalThread=Threadcount;
while(1)
{
dRet=::MsgWaitForMultipleObjects(Threadcount,hThreadp,FALSE,INFINITE,QS_ALLINPUT);
if(dRet==WAIT_OBJECT_0+Threadcount)
{
while (PeekMessage(&msg,NULL,0,0,PM_REMOVE))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
if (dRet>=WAIT_OBJECT_0 && dRet<WAIT_OBJECT_0+Threadcount)
{
nExitThreadCount++;
if(Threadcount!=0){
int Index=dRet-WAIT_OBJECT_0;
hThreadp[Index]=hThreadp[Threadcount-1];
hThreadp[Threadcount-1]=NULL;
Threadcount--;}
else
{break;}
}
}
------解决方案--------------------
你线程卡住了吧, 估计
DWORD dRet=0;
MSG msg;
//int nExitThreadCount=0,totalThread=Threadcount;
while(1)
{
dRet=::MsgWaitForMultipleObjects(Threadcount,hThreadp,FALSE,INFINITE,QS_ALLINPUT);
if(dRet==WAIT_OBJECT_0+Threadcount)
{
while (PeekMessage(&msg,NULL,0,0,PM_REMOVE))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
if (dRet>=WAIT_OBJECT_0 && dRet<WAIT_OBJECT_0+Threadcount)
{
nExitThreadCount++;
if(Threadcount!=0){
int Index=dRet-WAIT_OBJECT_0;
hThreadp[Index]=hThreadp[Threadcount-1];
hThreadp[Threadcount-1]=NULL;
Threadcount--;}
else
{break;}
}
}
------解决方案--------------------
你线程卡住了吧, 估计