Hi I know there is alot of the same question out here already but I tried every single one of them and can't seem to get why it won't work.
Here is my code
Private Sub CallbackProcessAsync(sender As Object, args As System.Diagnostics.DataReceivedEventArgs)
Console.WriteLine(args.Data)
Me.Invoke(Sub() statusRichText.AppendText(args.Data & Environment.NewLine))
End Sub
Sub SuperUpload()
Dim oProcess As New Process()
AddHandler oProcess.ErrorDataReceived, AddressOf CallbackProcessAsync
AddHandler oProcess.OutputDataReceived, AddressOf CallbackProcessAsync
Dim oStartInfo As New ProcessStartInfo("C:\Users\RKjetski\AppData\Local\Programs\Python\Python37\python.exe", "test.py " + vInfoIframe.Text + " " + vInfoID.Text)
oStartInfo.UseShellExecute = False
oStartInfo.CreateNoWindow = True
oStartInfo.RedirectStandardError = True
oStartInfo.RedirectStandardOutput = True
oProcess.EnableRaisingEvents = True
oProcess.StartInfo = oStartInfo
oProcess.Start()
oProcess.BeginErrorReadLine()
oProcess.BeginOutputReadLine()
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles btnSuperUpload.Click
Dim thread = New System.Threading.Thread(AddressOf SuperUpload)
thread.Start()
End Sub
The python file
import time
x = 0
while x < 5:
print(x)
time.sleep(2)
x = x +1
I get the following output but it's not live / in real time, the rich text box is empty until it read the program and then it prints everything instantly. 0 1 2 3 4