繁忙的应用程序导致错误的“无响应"Windows 7 上的状态 - WM_UPDATE
在长期操作过程中,我们的 C++ Win32 应用程序会显示一个带有进程栏的模式状态对话框,该进程栏每隔几秒左右就会不定期更新.从 Windows 7 开始,我们意识到 Windows 很快就会显示一条消息似乎挂起..."和/或将未响应"附加到我们的窗口标题栏.
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.
我们发现进程对话框必须处理消息以避免这种情况.更具体地说,Windows 7 似乎不断发送 WM_UPDATE 消息来检查我们的程序是否处于活动状态.我们之前在此对话框中禁用了所有不需要的消息处理,因为配置文件运行显示它们严重降低了速度.
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.
但尽管我们认为已经解决了问题,但用户再次报告此类问题:Windows 显示似乎挂起..."和/或在我们的窗口标题栏附加未响应",尽管我们每隔几次处理一次所有事件秒.
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.
问题:
是否有关于 Windows 7(或 Windows vista)中这种行为变化的文档?我们还没有找到.我们还发现了许多其他消息传递行为的变化.
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.
有没有办法从 Windows 禁用所有此类活动"检查?我们的应用程序运行良好,处理过程可能需要很长时间.
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.
更具体地说 - 我们每隔几秒才做一次调用消息泵 PeekMessage
/TranslateMessage
/调度消息
.
To be more specific - what we only do each few seconds is calling the message pump PeekMessage
/TranslateMessage
/DispatchMessage
.
由于这是一个相当古老的遗留程序,在不久的将来使用单独的工作线程是不可能的.我们当然会为新代码这样做.另请注意,我的主要观点是 Windows vista/Windows 7 肯定会改变这种行为.我还没有找到任何相关文档.
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.
推荐答案
嗯,直接回答你的问题,你可以调用DisableProcessWindowsGhosting()
.
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.
相关文章