Posts

Showing posts from April, 2011

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. 1: using System.Diagnostics; 2:   3: class MyClass 4: { 5: void RunProcess() 6: { 7: Process p = new Process(); 8: p.EnableRaisingEvents = true ; 9: p.Exited += new EventHander(Process_Exited); 10: } 11:   12: }