views:

171

answers:

2

How can you detect if your MFC application is not responding?

+2  A: 

Either the same application can start a separate thread, or some other application can run its own thread and periodically call SendMessageTimeout() to send the WM_NULL message to the application in question. If it times out it means that the application is irresponsive.

sharptooth
A: 

If you're asking how to do it from within the process itself, you can't, it's a paradox. A blocked process can't detect if it is not responding. It'd be like someone waking himself up to ask himself if he's sleeping.

Based on this and your other question, I'd guess you have a long-running operation and you want the user to wait until it's finished. If they click your window before it's done they get "not responding" and may terminate the application too early.

You need to perform the long-running operation on a separate thread. Here's a great starting point: CodeProject article

Aidan Ryan