| 91 | } |
| 92 | |
| 93 | void CProtectedWinThread::PumpMessages() |
| 94 | { |
| 95 | ASSERT_VALID(this); |
| 96 | |
| 97 | // for tracking the idle time state |
| 98 | BOOL bIdle = TRUE; |
| 99 | LONG lIdleCount = 0; |
| 100 | #if _MFC_VER >= 0x0710 |
| 101 | _AFX_THREAD_STATE* pState = AfxGetThreadState(); |
| 102 | MSG &msgCur = pState->m_msgCur; |
| 103 | #else |
| 104 | MSG &msgCur = m_msgCur; |
| 105 | #endif /* _MFC_VER_ */ |
| 106 | |
| 107 | // acquire and dispatch messages until a WM_QUIT message is received. |
| 108 | for (;;) |
| 109 | { |
| 110 | // phase1: check to see if we can do idle work |
| 111 | while (bIdle && |
| 112 | !::PeekMessage(&msgCur, NULL, NULL, NULL, PM_NOREMOVE)) |
| 113 | { |
| 114 | // call OnIdle while in bIdle state |
| 115 | if (!OnIdle(lIdleCount++)) |
| 116 | bIdle = FALSE; // assume "no idle" state |
| 117 | } |
| 118 | // phase2: pump messages while available |
| 119 | do |
| 120 | { |
| 121 | // pump message, but quit on WM_QUIT |
| 122 | if (!PumpMessage()) { |
| 123 | #if defined(_DEBUG) |
| 124 | # if _MFC_VER < 0x0710 |
| 125 | m_nDisablePumpCount--; // application must NOT die |
| 126 | # else |
| 127 | pState->m_nDisablePumpCount--; // application must NOT die |
| 128 | # endif |
| 129 | #endif |
| 130 | return; |
| 131 | } |
| 132 | |
| 133 | // reset "no idle" state after pumping "normal" message |
| 134 | if (IsIdleMessage(&msgCur)) |
| 135 | { |
| 136 | bIdle = TRUE; |
| 137 | lIdleCount = 0; |
| 138 | } |
| 139 | |
| 140 | } while (::PeekMessage(&msgCur, NULL, NULL, NULL, PM_NOREMOVE)); |
| 141 | } |
| 142 | |
| 143 | ASSERT(FALSE); // not reachable |
| 144 | } |
| 145 | |
| 146 | bool CProtectedWinThread::PumpWaitingMessages(UINT firstMsg, UINT lastMsg) |
| 147 | { |
no outgoing calls
no test coverage detected