I have following code, but why is the ProcessExited
method never called? It is the same if I don't a use Windows shell (startInfo.UseShellExecute = false
).
ProcessStartInfo startInfo = new ProcessStartInfo();
startInfo.CreateNoWindow = true;
startInfo.UseShellExecute = true;
startInfo.WindowStyle = ProcessWindowStyle.Hidden;
startInfo.FileName = path;
startInfo.Arguments = rawDataFileName;
startInfo.WorkingDirectory = Util.GetParentDirectory(path, 1);
try
{
Process correctionProcess = Process.Start(startInfo);
correctionProcess.Exited += new EventHandler(ProcessExited);
correctionProcess.WaitForExit();
status = true;
}
.....
internal void ProcessExited(object sender, System.EventArgs e)
{
//print out here
}
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…