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를 사용하여
, 그것은 같이 보입니다.
일반적으로 이러한 데이터 수집을 처리하지 못합니다. –