if wpf app is not responding, then auto restart

前端 未结 2 1684
孤独总比滥情好
孤独总比滥情好 2021-01-03 13:56

I have a WPF application that occasionally crashes, and say \"not responding\". Is there a way to detect if the program is not responding? And if so, restart the WPF applica

2条回答
  •  悲&欢浪女
    2021-01-03 14:43

    Because this is a temporary fix while you debug the app, one possibility is to cheat and use a bootstrapper/startup app whose sole job is to monitor the problematic app. Start the problematic application via the System.Diagnostics.Process class's Start method, then occasionally monitor the returned Process' Responding property. If not responding, do what you need to do.

    It's important that this only be done as a stopgap while you fix the real problem, of course. There are lots of little issues with doing something like this long-term.

提交回复
热议问题