C# 启动Nginx调试发现ErrorDataReceived被回调了两次,这是什么原因?
本文介绍了C# 启动Nginx调试发现ErrorDataReceived被回调了两次,这是什么原因?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
问 题
这是启动代码:
ps = new Process();
ps.StartInfo.FileName = exe;
ps.StartInfo.Arguments = args;
ps.StartInfo.UseShellExecute = false;
ps.StartInfo.RedirectStandardOutput = true;
ps.StartInfo.RedirectStandardError = true;
ps.StartInfo.WorkingDirectory = workingDir;
ps.StartInfo.CreateNoWindow = true;
ps.EnableRaisingEvents = true;
ps.ErrorDataReceived += Ps_ErrorDataReceived;
ps.Start();
ps.BeginOutputReadLine();
ps.BeginErrorReadLine();
if (wait) {
ps.WaitForExit();
ps.Close();
}
Ps_ErrorDataReceived里我打印了e.Data,发现第一次是错误,第二次是个null,
这是什么原因呢?
解决方案
应该是输出了一个终结标志吧。
这篇关于C# 启动Nginx调试发现ErrorDataReceived被回调了两次,这是什么原因?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文