public void ExecuteProcessChain(string[] asProcesses,string sInRedirect,string sOutRedirect) { Process p1 = new Process(); p1.StartInfo.UseShellExecute = false; p1.StartInfo.RedirectStandardOutput = true; p1.StartInfo.FileName = asProcesses[0]; p1.Start(); StreamReader sr = p1.StandardOutput; string s,xxx = ""; while ((s = sr.ReadLine()) != null) Console.WriteLine("sdfdsfs"); //xxx += s+"\n"; p1.StartInfo.RedirectStandardInput = true; p1.StartInfo.RedirectStandardOutput = false; p1.StartInfo.FileName = asProcesses[1]; p1.Start(); StreamWriter sw = p1.StandardInput; sw.Write(xxx); sw.Close(); sr.Close(); }
我正在尝试执行“calc | calc”,但是当我这样做时,它会卡在线上而((s = sr.ReadLine())!= null)并且只有在我关闭计算器之后代码才会继续.我需要两个计算器一起工作.你知道怎么做吗?
解决方法
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。