How does Windows know when a program is not responding?

570 views

How does Windows know when a program is not responding?

In: 1

5 Answers

Anonymous 0 Comments

Each application has a message queue. Every time something happens (mouse moves, key pressed, window needs to be redrawn, timer expires, etc) windows adds a message to the queue for the application. The application needs to handle the message within a few seconds or Windows will think the application is not responding. Once the application starts processing messages again the error goes away.

The answer directly from Microsoft:

> The operating system detects this state by attaching a timer to pending messages in the message queue. If a message has not been retrieved within 5 seconds, the DWM declares the window to be hung.

https://docs.microsoft.com/en-us/windows/win32/win7appqual/preventing-hangs-in-windows-applications

You are viewing 1 out of 5 answers, click here to view all answers.