Detecting Process Completion
using System;
using System.Diagnostics;
public class DetectingProcessCompletion
{
static void ProcessDone(object sender, EventArgs e)
{
Console.WriteLine("Process Exited");
}
public static void Main()
{
Process p = new Process();
p.StartInfo.FileName = "notepad.exe";
p.StartInfo.Arguments = "process3.cs";
p.EnableRaisingEvents = true;
p.Exited += new EventHandler(ProcessDone);
p.Start();
p.WaitForExit();
Console.WriteLine("Back from WaitForExit()");
}
}
Related examples in the same category