これを使用して、コントローラーのアクションからプロセスを実行します
var psi = new ProcessStartInfo(utilityPath, String.Format("{0} {1}", inputfilePath, outputfilePath))
{
WorkingDirectory = Environment.CurrentDirectory,
UseShellExecute = false,
RedirectStandardOutput = true,
RedirectStandardError = true,
CreateNoWindow = true
};
using (var process = new Process { StartInfo = psi })
{
process.EnableRaisingEvents = true;
process.OutputDataReceived += new DataReceivedEventHandler(process_OutputDataReceived);
process.ErrorDataReceived += new DataReceivedEventHandler(process_OutputDataReceived);
process.Exited += new EventHandler(process_Exited);
// start the process and start reading the standard and error outputs
process.Start();
process.BeginErrorReadLine();
process.BeginOutputReadLine();
//process.WaitForExit(); //If this is commented out the delegate process_Exited never fires
}
process.WaitForExit();
なんらかの理由で使用しないと、ここに登録されたデリゲートprocess.Exited += new EventHandler(process_Exited);
は決して発火しません。
ここで何が間違っていますか?