我开始一个使用process.exited
来发送程序指令,指示如何处理完成的进程。C#通过Process.Exited发送参数
它工作正常,但我需要发送一个参数到Process_Exited()
方法。这样的事情:
process.exited += Process_Exited(jobnumber);
但这并不奏效。这里是我的代码:
public void x264_thread(string jobnumber, string x264_argument, string audio_argument)
{
file = new System.IO.StreamWriter("c:\\output\\current.out");
mysqlconnect("UPDATE h264_encoder set status = 'running' where jobnumber = '" + jobnumber + "'");
var proc = new Process();
proc.StartInfo.FileName = "C:\\ffmbc\\ffmbc.exe";
proc.StartInfo.Arguments = x264_argument;
proc.StartInfo.UseShellExecute = false;
proc.StartInfo.RedirectStandardOutput = true;
proc.StartInfo.RedirectStandardError = true;
proc.EnableRaisingEvents = true;
proc.StartInfo.CreateNoWindow = true;
proc.ErrorDataReceived += proc_DataReceived;
proc.OutputDataReceived += proc_DataReceived;
proc.Exited += process_Exited(JobNumber); //This is where I would like to include a argument
proc.Start();
proc.BeginErrorReadLine();
proc.BeginOutputReadLine();
}
然后转到process_Exited
方法:
public void process_Exited(object sender, EventArgs e, string JobNumber) //This does not work. It does not pass the string JobNumber
{
//Do Stuff
}
我想从x264_thread发送process_Exited()
方法的参数
它是'进程' - 一个'c',两个's' .. –