“程序没有响应”是什么意思?

What does « program is not responding » mean?

此消息是什么意思,是否有 API 来“响应”Microsoft Windows 状态查询?

我正在寻找技术答案。谢谢:)

这意味着程序无法为其消息队列提供服务。来自 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.

通常这意味着程序的主线程很忙并且没有足够频繁地调用 GetMessage。长 运行 任务应在主 UI 线程以外的线程上执行。

Windows 应用程序通过接收 window 消息与操作系统交互。这些消息由应用程序在其主线程中循环处理。

如果一个应用程序未能及时处理它的消息(几秒钟是那里的余量),它的消息队列就会填满并且Windows将这个应用程序标记为"not responding",呈现它的主要window 白发之类的。

此类行为主要是由于在处理 window 消息的同一线程上执行冗长操作造成的。此线程通常称为 "main UI thread"。如果您不执行任何显式多线程,它很可能是您应用程序的唯一线程。