What does « program is not responding » mean?

Deadly 提交于 2019-12-23 17:31:28

问题


What does this message means, is there an API to « respond » to Microsoft Windows status queries ?

I'm looking for a technical answer. Thanks :)


回答1:


What this means is that the program is failing to service its message queue. From the documentation:

If a top-level window stops responding to messages for more than several seconds, the system considers the window to be not responding. In this case, the system hides the window and replaces it with a ghost window that has the same Z order, location, size, and visual attributes. This allows the user to move it, resize it, or even close the application. However, these are the only actions available because the application is actually not responding. When in the debugger mode, the system does not generate a ghost window.

Typically this means that the main thread of the program is busy and is not calling GetMessage frequently enough. Long running tasks should be performed on a thread other than the main UI thread.




回答2:


Windows applications interact with the operating system by receiving window messages. These messages are processed by the application in its main thread in a loop.

If an application fails to process its messages in time (several seconds are the margin there), its message queue fills up and Windows marks this application as "not responding", rendering its main window white-ish and the such.

Such behaviour is mostly caused by doing a lengthy operation on the same thread that processes the window messages. This thread is often referred to as the "main UI thread". If you do not do any explicit multi threading, it may well be the only thread of your application.



来源:https://stackoverflow.com/questions/30592746/what-does-program-is-not-responding-mean

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!