一个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;}
}
}
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;}
}
}
...全文
相关推荐
定时函数的应用综述.pdf
在创建窗口时应避免长时间使用Sleep,可能导致消息处理阻塞,这时可以考虑使用MsgWaitForMultipleObjects或MsgWaitForMultipleObjectsEx代替。2.
定时函数的应用综述.docx
**Sleep函数**:这是一个Windows API函数,用于使当前线程暂停指定的毫秒数。其精度较低,受系统负载和线程优先级等因素影响,可能导致实际休眠时间与期望值有所偏差。
易语言超级延时模块
易语言超级延时模块源码 系统结构:超级延时,CreateWaitableTimerA,SetWaitableTimer,MsgWaitForMultipleObjects, ======程序集1 |
定时函数的应用综述.doc
**Sleep 函数**:Sleep 函数是最基础的延时函数,通常用于线程暂停执行。它的参数是以毫秒为单位的,但其精度较低,受到系统负载和线程调度的影响。
易语言按钮滑动效果
易语言按钮滑动效果源码系统结构:线程启动,优化池,SetWaitableTimer,CloseHandle,MsgWaitForMultipleObjects,CreateWaitableTimerA


进程/线程/DLL
