windows messages
Just thinking out loud:
If you only do a pure window app and don't need to do the extra processing when the window doesn't get any messages, then PeekMessage is a waste of resources, because, look at the processor usage, it will spike close to 100% (or 50% if you have dual-core or hyper threading). In those scenarios, use GetMessage, it will put your app in a sleep state until a message is available, not using processing power. Also, you should test with the WM_CLOSE message, because that won't be passed to you windowProc...
Julian
If you only do a pure window app and don't need to do the extra processing when the window doesn't get any messages, then PeekMessage is a waste of resources, because, look at the processor usage, it will spike close to 100% (or 50% if you have dual-core or hyper threading). In those scenarios, use GetMessage, it will put your app in a sleep state until a message is available, not using processing power. Also, you should test with the WM_CLOSE message, because that won't be passed to you windowProc...
Julian
yeah, i'll also second with AP and that if you don't need PeekMessage, you shouldn't use it. and even if you have to, you should always call GetMessage (something like below):
for(;;) { if(PeekMessage(&msg, 0, 0, 0, 0, PM_NOREMOVE)) { if(GetMessage(&msg, 0, 0, 0, 0) { TranslateMessage(&msg); DispatchMessage(&msg); } else break; } else { // idle processing } }
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement