Rather than locating it to the textbox, loop to the number of lines and save each line in a string and send that string to the application you want to send to.
Async ProcessStartInfo : Run cmd program to show in textbox just like cmd window in real time
-
29-05-2022 - |
سؤال
I am trying to run an exe program that outputs to the command box. I am redirecting the output to show in a textbox, but it seems to only show the entire results when the program is finished. I want it to display one line at a time as it executes.
THIS IS MY CODE:
Dim startInfo As ProcessStartInfo = New ProcessStartInfo(SomeDOScmd.exe)
startInfo.Arguments = some args
startInfo.CreateNoWindow = True
startInfo.UseShellExecute = False
startInfo.ErrorDialog = False
startInfo.RedirectStandardOutput = True
Dim pr As Process = Process.Start(startInfo)
pr.BeginOutputReadLine()
AddHandler pr.OutputDataReceived, AddressOf ShowOutput
pr.WaitForExit()
pr.Close()
pr.Dispose()
Private Sub ShowOutput(sendingProcess As Object, _
outLine As DataReceivedEventArgs)
txtShow.text += outLine.Data
End Sub
Seems to me this should work, according to MSDN anyway, but it doesn't.
المحلول
لا تنتمي إلى StackOverflow