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


 

Comments (5)

  1. Calvin,

    This is very interesting…

    On a related-note, I’d like to mention that it is VERY RARE for VFP 9.0 to be reported as "NOT RESPONDING". I can’t say enough good things about this release of Visual FoxPro.

    Thanks for this always interesting blog and for the intellectual/technical resources dedicated to making the BEST database.

    Regards from San Juan, Puerto Rico – USA.

  2. I received a comment on this post: Will GetLastError ever work properly in VFP8.0?.  I was consistently…

  3. I was asked why Tooltips appear in Task Manager. I happened to be out of the country when the question…

  4. ... says:

    um… buoni, realmente buoni luogo e molto utile;)

  5. I spent a few hours at a local company called 2Bot ( http://www.2bot.com/ ) which makes a 3-D printer