例如: 主线程中一个对话框的按钮事件如下:
for(int i=0; i<1000; i++)
{
Sleep(10);
if(i%100)
{
MSG msg;
while(::PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE))
{
if(!theApp.PumpMessage())
{
::PostQuitMessage(0);
return;
}
}
}
}
如果将
if(i%100)
{
MSG msg;
while(::PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE))
{
if(!theApp.PumpMessage())
{
::PostQuitMessage(0);
return;
}
}
}
去掉后,只有执行完该函数后 主线程的其他消息才能响应 导致拖动界面操作无法执行