beardudeguy
Programmer
Im trying to start a process asyncronously and then run other code, but use the System.Diagnostics.Process.Exited (or other method) to go back and restart it if it closes.
this is waht i came up with, but exited doesnt get called even if i close the program (notepad) that is started
this is waht i came up with, but exited doesnt get called even if i close the program (notepad) that is started
Code:
public class pcntrl
{
private System.Diagnostics.ProcessStartInfo psi = new System.Diagnostics.ProcessStartInfo();
private System.Diagnostics.Process cmd = new System.Diagnostics.Process();
public pcntrl(string filename, string args)
{
this.psi.FileName = filename.ToString();
this.psi.Arguments = args.ToString();
}
public void start()
{
this.cmd.EnableRaisingEvents = true;
this.cmd.Exited += new System.EventHandler(this.exited);
this.cmd = System.Diagnostics.Process.Start(this.psi);
this.cmd.PriorityClass = System.Diagnostics.ProcessPriorityClass.Normal;
}
private void exited(object sender, EventArgs e)
{
Console.WriteLine("exited called");
}
}