C# プロジェクトで別の exe のコンソールを 1 行ずつ読んでいます。プロジェクトは各コンソール行を正常に読み取りますが、直面している問題は、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);
}
}
}
この問題にどのように取り組むべきですか、親切に私を導いてください