Reputation: 1114
The Windows 7 window manager regularly detects my WPF app as being hung, ghosts it and pops up a not responding message. I've been using the app for several weeks and haven't seen it but a user with the same hardware as me says he gets it regularly.
Everything that can be is run in a task on another thread, so I'm not sure where to begin looking for the issue. If the user waits for the application to respond it recovers quickly so I'm assuming the issue is something on the GUI thread that occasionally takes just over 5 seconds to run.
Is there any way I can detect when the DWM thinks the app has hung so I can log a stack trace?
Upvotes: 5
Views: 792
Reputation: 28829
I haven't done this in a WPF app, but the traditional way would be to send a WM_NULL message from a background thread every so often using SendMessageTimeout, and if the main UI thread doesn't process the message in, say, 30 seconds, generate a stack dump for that thread.
Upvotes: 1
Reputation: 12458
One approach is to write a trace of your program using System.Diagnostics
namespace. With that you can find out what the last action was before your program hangs up. You will hardly inspect a program when Windows considers it as being hung. :-(
Upvotes: 1