Back

Handling Events on System.Diagnostics.Process

If you want to handle events when working with System.Diagnostics.Process – for example, the Exited event – you have to first enable the raising of events using the EnableRaisingEvents property on Process.

using System.Diagnostics;

class MyClass
{
    void RunProcess()
    {
        Process p = new Process();
        p.EnableRaisingEvents = true;
        p.Exited += new EventHander(Process_Exited);
    }
}

Questions?

Questions, comments, concerns? Give us a Tweet!