GetMessage()
の代わりにPeekMessage()
を使用するようにメッセージポンプを変更することができます。これにより、メッセージループがアイドル状態のときにメッセージが利用可能になったときに処理したり、何か他のことを行うことができます。
for (bool running = true; running;)
{
// check for any window messages. this operation does not block
// if no messages are available.
::MSG message;
const ::BOOL fetched = ::PeekMessage(&message, 0, 0, 0, PM_REMOVE);
if (fetched)
{
// process window message.
TranslateMessage(&message);
DispatchMessage(&message);
// need to check explicitly for WM_QUIT message, since the "false"
// return value is already used to mean "there were no messages".
running = (message.message != WM_QUIT);
}
else
{
// no messages available, thread is idle. take time to check
// auxiliary input source. if no auxiliary input is available
// and checking (and processing) the auxiliary inputs is very
// fast, consider adding an extra ::Sleep() call to avoid hogging
// up the CPU.
}
}
.NETベースのアプリケーションでは、あなたがApplication.Idle
イベントを見てみることをお勧めします:
のWin32 APIを使用して
が、それはのようになります。
通常、このようなデータ収集は処理されません。 –