( WaitForExit), .
Process Exited, . Process, Exited, Start; , Process.Start, , Process.Start , , , .
Proof of concept: (does not handle Dispose, access to the queue is not thread safe, although it should be sufficient if it is really serial and so on)
Queue<Process> ProcessesToRun = new Queue<Process>(new []{ new Process("1"), new Process("2"), new Process("3") });
void ProcessExited(object sender, System.EventArgs e) {
GrabNextProcessAndRun();
}
void GrabNextProcessAndRun() {
if (ProcessesToRun.Count > 0) {
Process process = ProcessesToRun.Dequeue();
process.Exited += ProcessExited;
process.Start();
}
}
void TheEntryPoint() {
GrabNextProcessAndRun();
}
source
share