我正在尝试使用以下代码读取控制台进程的全部内容(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)
然而,当尝试使用'ReadToEnd'时,应用程序似乎会暂停,我认为这是因为控制台进程是连续输出的,永远不会真正结束。'ReadLine'可以正常工作,但只能获取第一行,而我需要在那个阶段获取整个控制台的内容。
我该如何解决这个问题?