我在我的 C# 项目中逐行读取另一个 exe 的控制台,该项目成功读取了每个控制台行,但我面临的问题是当 exe 开始执行时,我的 c# 表单挂起,它一直等到外部 exe 没有完全执行.
ProcessStartInfo startInfo = new ProcessStartInfo();
startInfo.CreateNoWindow = true;
startInfo.UseShellExecute = false;
startInfo.FileName = EXELOCATION;
startInfo.WindowStyle = ProcessWindowStyle.Hidden;
startInfo.Arguments = argv;
startInfo.RedirectStandardOutput = true;
try
{
// Start the process with the info we specified.
// Call WaitForExit and then the using statement will close.
using (exeProcess = Process.Start(startInfo))
{
using (StreamReader reader = exeProcess.StandardOutput)
{
string result;
while ((result = reader.ReadLine() ) != null)
{
scanning.Text = result;
scanning.Refresh();
Console.Write(result);
}
}
}
我该如何解决这个问题,请指导我