我正在尝试使用以下代码读取控制台进程的全部内容(3秒后):
Dim NewProcess As New System.Diagnostics.Process()
With NewProcess.StartInfo
.FileName = EXE_PATH
.RedirectStandardOutput = True
.RedirectStandardError = True
.RedirectStandardInput = True
.UseShellExecute = False
.WindowStyle = ProcessWindowStyle.Normal
.CreateNoWindow = False
End With
NewProcess.Start()
System.Threading.Thread.Sleep(3000)
MsgBox(NewProcess.StandardOutput.ReadToEnd)
Run Code Online (Sandbox Code Playgroud)
但是,当尝试'ReadToEnd'时应用程序似乎暂停,我认为这是因为控制台进程是一个连续的输出,永远不会真正结束.'ReadLine'工作正常,但只获得第一行,但我需要在该阶段控制台的全部内容.
我怎么解决这个问题?