views:

13

answers:

1

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 (myProcesses.Length > 0)
        {
            foreach (Process proc in myProcesses)
            {
                _Logger.LogMessage("Check responding");
                if (!proc.Responding)
A: 

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.

Richard
I have a idea to give enough possible time for application to respond. For example i give retry to check responding state for 4 minutes and if still it is not responding i want to restart it.
malik