How does Task Manager determine if an Application is Not Responding?

If you start Task Manager (Ctrl-Shift-Esc) and display the Applications tab, you will see a list of running applications. Once in a while an application shows as “Not Responding”.

How does Task Manager figure that out?

A simple way to determine the answer is to start Notepad and SPY++ (see Spy on your programs). Watch the messages that get sent to Notepad. You’ll see that the WM_GETICON message is sent to notepad when Task Manager starts up.

Task Manager tests to see if a SendMessage of WM_GETICON to the main application window returns. If not, it displays “Not Responding”. That doesn’t mean, however, that the process is dead.

VFP has a property called _VFP.AutoYield which determines whether pending Windows messages will be processed during program execution.

You can test to see if the UI thread and the processing thread are the same in VFP by executing this code and starting Task Manager

_vfp.AutoYield=.f.

FOR i = 1 TO 100000000

      xx="test string"

ENDFOR

For more about Autoyield: see Interesting form paint behavior