申请冻结在" StandardOutput.ReadLine()&QUOT ;. [英] Application Freezes on "StandardOutput.ReadLine()".

查看:225
本文介绍了申请冻结在" StandardOutput.ReadLine()&QUOT ;.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

应用程序挂起尝试调用StandardOutput.ReadLine()的时候。

Application hangs when attempting to call "StandardOutput.ReadLine()".

在code:

ProcessStartInfo startInfo = new ProcessStartInfo("c:\\windows\\system32\\myTesting.exe");
            String s = " ";

            startInfo.WindowStyle = ProcessWindowStyle.Hidden;
            startInfo.CreateNoWindow = true;
            startInfo.RedirectStandardInput = true;
            startInfo.RedirectStandardOutput = true;
            startInfo.UseShellExecute = false;
            Process p = Process.Start(startInfo);
            p.StandardInput.WriteLine("list volume\n");
            String f = "";

            while (!p.StandardOutput.EndOfStream)
                {
                    s = p.StandardOutput.ReadLine();
                }

死锁异常-error有时会发生,但并不总是

"Deadlock exception"-error occurs sometimes, but not always.

推荐答案

perhabs的wihle是问题。刚刚尝试这一点:

perhabs the wihle is the problem. Just try this:

// Create the child process.
 Process p = new Process();

 // Redirect the output stream of the child process.
 p.StartInfo.UseShellExecute = false;
 p.StartInfo.RedirectStandardOutput = true;

 //setting the application path
 p.StartInfo.FileName = "Write500Lines.exe";
 p.Start();

 // Do not wait for the child process to exit before
 // reading to the end of its redirected stream.
 // Read the output stream first and then wait.
 string output = p.StandardOutput.ReadToEnd();
 p.WaitForExit();

这篇关于申请冻结在" StandardOutput.ReadLine()&QUOT ;.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆