Busy Application leads to false "Not responding" state on Windows 7 - WM_UPDATE
Asked Answered
M

2

9

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/TranslateMessage/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.

Malevolent answered 9/8, 2011 at 13:56 Comment(2)
This shouts out for a background worker thread.Nifty
"disabled all unneeded message handling" - MSDN is quite clear on this subject: "If [a window procedure] does not process a message, it must send the message back to the system for default processing. The window procedure does this by calling the DefWindowProc function. "Royster
S
19

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.

Scarlatti answered 9/8, 2011 at 14:4 Comment(3)
Thanks for your answer. The Documentation says "Window ghosting is a Windows Manager feature that lets the user minimize, move, or close the main window of an application that is not responding.". It does not say anything about disabling of the "seems to hang note". Do you know anything more about that?Malevolent
When you disable ghosting you won't see any "(not responding)" text attached to the caption etc.Scarlatti
Also from a UX perspective, by using a different thread, you can use the current one to give feedback to your user about the progress of their task.Weisberg
D
2

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);
Donny answered 26/2, 2021 at 19:44 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.