MFC在什么情况下会发送空闲消息!!!

huyj_happy 2007-11-03 10:44:39
MFC在什么情况下会发送空闲消息!!!
int CWinThread::Run()
{
ASSERT_VALID(this);

// for tracking the idle time state
BOOL bIdle = TRUE;
LONG lIdleCount = 0;

// acquire and dispatch messages until a WM_QUIT message is received.
for (;;)
{
// phase1: check to see if we can do idle work
while (bIdle &&
!::PeekMessage(&m_msgCur, NULL, NULL, NULL, PM_NOREMOVE))
{
// call OnIdle while in bIdle state
if (!OnIdle(lIdleCount++))
bIdle = FALSE; // assume "no idle" state
}

// phase2: pump messages while available
do
{
// pump message, but quit on WM_QUIT
if (!PumpMessage())
return ExitInstance();

// reset "no idle" state after pumping "normal" message
if (IsIdleMessage(&m_msgCur))
{
bIdle = TRUE;
lIdleCount = 0;
}

} while (::PeekMessage(&m_msgCur, NULL, NULL, NULL, PM_NOREMOVE));
}

ASSERT(FALSE); // not reachable
}
从上面这段源代码,可以知道一旦收到消息,MFC会中止空闲处理,不论是否已经处理完成。收到消息后会调用IsIdleMessage判断是否需要调用OnIdle,那么问题就来了,在什么情况下MFC会发送空闲消息?
...全文
83 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
XiangDong 2007-11-04
  • 打赏
  • 举报
回复
1. OnIdle不会中断执行,这就是为什么我们不能再OnIdle处理函数中执行费时的操作。
2. OnIdle会在PeekMessage没有收到任何消息的时候执行。

15,471

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC 进程/线程/DLL
社区管理员
  • 进程/线程/DLL社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧