Busy Application leads to false "Not responding" state on Windows 7 - WM_UPDATE
During long term operations our C++ Win32 application shows a modal status dialog with a process bar, which is updated irregular every few seconds or so. Starting with Windows 7 we realized that Windows quite soon shows a message " seems to hang..." and/or appends "Not responding" to our window title bar.
We figured out that the process dialog must handle messages to avoid this. More specifically it seems that Windows 7 is constantly sending WM_UPDATE messages to check if our program is alive. We formerly had disabled all unneeded message handling in this dialog as profile runs shows that they were a major slow down.
But although we thought to have fixed that problem users are reporting such problems again: Windows shows " seems to hang..." and/or appends "Not responding" to our window title bar, although we handle all events every few seconds.
Questions:
Is there any documentation about this change of behavior in Windows 7 (or Windows vista)? We haven't found any. We also found a number of other changes of messaging behavior.
Is there possibly a way to disable all such "is alive" checks from windows? Our Application is pretty well alive and processes can take quite long.
EDIT: To be more specific - what we only do each few seconds is calling the message pump PeekMessage
/TranslateMes开发者_开发知识库sage
/DispatchMessage
.
As this is a quite old legacy program, using a separate worker thread is not possible in the near future. We of course do that for new code. Please note also that my main point is that this behavior definitely changed with Windows vista / Windows 7. I have not found any documentation thereabout.
Well, the direct answer to your question is that you can call DisableProcessWindowsGhosting()
.
However, it would be much better to address the root of the problem rather than suppress the symptoms. Your window is being ghosted because you aren't pumping the message queue. You aren't doing that for the admirable reason that your application is busy doing work. The accepted way to do work and keep your queue pumped, is to do the work in a separate thread.
I've found out that an application does not need to perform the actual message processing to prevent the "(not responding)" state while executing a blocking task in the main thread.
It just needs to periodically call:
PeekMessage(&msg, 0, 0, 0, PM_NOREMOVE);
精彩评论