I have a process which runs python in the background in order to receive the inputs and outputs. My program works with multiple outputs but only allows one input otherwise the program freezes. If the python.exe wants different values for the new user inputs how will I do this?
VB.net
Public Value As String
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click 'Works on button
Dim p As Process = New Process
p.StartInfo.FileName = "C:\Users\luqma\AppData\Local\Programs\Python\Python38-32\python.exe" 'Default Python Installation
p.StartInfo.Arguments = "File.py"
p.StartInfo.UseShellExecute = False 'required for redirect.
p.StartInfo.WindowStyle = ProcessWindowStyle.Hidden 'don't show commandprompt.
p.StartInfo.CreateNoWindow = True
p.StartInfo.RedirectStandardInput = True
p.StartInfo.RedirectStandardOutput = True 'captures output from commandprompt.
p.StartInfo.RedirectStandardError = True
p.Start()
AddHandler p.OutputDataReceived, AddressOf process_OutputDataReceived
p.StandardInput.WriteLine(TextBox2.Text)
p.StandardInput.WriteLine(TextBox2.Text) 'Freezes with this input added. Only works with one use input
p.BeginOutputReadLine()
SimpleEditor1.Text = Value
p.WaitForExit()
End Sub
Public Sub process_OutputDataReceived(ByVal sender As Object, ByVal e As DataReceivedEventArgs)
On Error Resume Next
If e.Data = "" Then
Else
Value += ">" + e.Data + Environment.NewLine
End If
End Sub
Python code I'm trying to do
print("bye")
print("Hello")
i = int(input("Enter num:"))#RUNS WHEN THERE IS ONLY THIS INPUT
print(i+1)
q = int(input("Enter num:"))#FREEZES WHEN THIS IS IN THE PYTHON FILE
print(q+5)
Thanks for the assistance