Log stack trace when Windows detects application freezes

Window Manager Windows 7 regularly discovers that my WPF app is what he had seen , prividyaet it and issues a message not responding. I have been using the application for several weeks and have not seen it, but a user with the same equipment as me says that he regularly receives it.

Everything that can be run in a task in another thread, so I'm not sure where to start looking for a problem. If the user is waiting for the application to respond, it is quickly restored, so I assume that the problem is with the GUI thread, which sometimes takes a little more than 5 seconds.

Is it possible to detect when DWM considers the application to freeze, so I can write a stack trace?

+5
source share
2 answers

I did not do this in a WPF application, but the traditional way would be to send a WM_NULL message from the background thread so often using SendMessageTimeout, and if the main user interface thread does not process the message, say, 30 seconds, create a stack dump for this thread.

+1
source

One approach is to write a trace of your program using a namespace System.Diagnostics. With this, you can find out what was the last action before your program freezes. You are unlikely to check the program when Windows considers it to be suspended .: - (

+1
source

All Articles