This web site uses cookies. By using the site you accept the cookie policy.This message is for compliance with the UK ICO law.

System Information
.NET 1.1+

Detecting Processes that are not Responding

If you are developing software that monitors other programs or services, it can be useful to detect when a process has stopped responding to the user. This can easily be achieved using members of the .NET framework's Process class.

Process Class

The Process class can be found in the System namespace. This class provides a series of static and instance members that allow you to connect to running processes on the local machine or remote machines. Once connected, you can interrogate, start and stop those processes. The Process class can be used to determine whether a process is still responding or whether it has "hung". This is useful when you are developing software that monitors other processes, programs or services.

In this article we will create a simple console application that outputs the list of processes executing on the current machine and indicates whether they are active or have stopped responding to user actions. This will use the Process class so ensure that you include the following using directive:

using System.Diagnostics;

Checking that Processes are Responding

To determine whether a process has hung, we can attach a Process object to it and read the Responding property. This property returns a Boolean value, where true indicates an active process and false specifies that the program is failing to react to user input. The following simple code obtains a list of every running process on the local machine. It then checks each object's Responding flag within a for-each loop and outputs a message indicating the status of the process.

Process[] processes = Process.GetProcesses();
foreach (Process p in processes)
    if (p.Responding)
        Console.WriteLine(" is reponding.");
        Console.WriteLine(" IS NOT RESPONDING.");
9 June 2010