开发者

How to check application is halt or working from a window service

开发者 https://www.devze.com 2022-12-26 06:41 出处:网络
I have one WPF application and one windows service as watch dog. I want to check if my window application is halt or working fine. If it is halt i want to restart the application.

I have one WPF application and one windows service as watch dog.

I want to check if my window application is halt or working fine. If it is halt i want to restart the application.

I see Process.responding property but it is not working in my service.

Any idea or other solution.

 Process[] myProcesses;
        myProcesses = Process.GetProcessesByName(ApplicationName);
        if (myP开发者_运维技巧rocesses.Length > 0)
        {
            foreach (Process proc in myProcesses)
            {
                _Logger.LogMessage("Check responding");
                if (!proc.Responding)


In general you cannot detect if a program has halted (lookup "The Halting Problem").

If you have a specific technical definition of "halt" for your case then it might be possible, but the details are everything.

Consider a GUI then is waiting for a network request, so stops processing input... but when the request completes it will start responding. In this case it has halted by one definition, but not in other senses.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号