I have an app that runs a background process and I need to show that app's standard out during execution, like real time. I tried process.OutputDataReceived
but it triggered after background process terminated itself. But I need to show standard output when that out is created by the process.
FYI: I redirected standard output and set UseShellExecute
false
Here is full changes I did to the process:
ProcessStartInfo t = new ProcessStartInfo();
t.CreateNoWindow = true;
t.FileName = name;
t.Arguments = args;
t.UseShellExecute = false;
t.CreateNoWindow = true;
t.RedirectStandardOutput = true;
t.RedirectStandardError = true;
Process p = new Process();
p.StartInfo = t;
p.OutputDataReceived += P_OutputDataReceived;
p.Start();
p.BeginOutputReadLine();
And my event:
private void P_OutputDataReceived(object sender, DataReceivedEventArgs e)
{
Textbox1.Text = e.Data;
}
Also I tried this with a python file, an executable version of it, and a C files executable, but same result at all of them.
Edit: I tried this solution but got the same result again
**Update 04.06.2018: **I just found that the P_OutputDataReceived
event is also triggeredn when app waits for standart input, but still cannot found a way to trigger that event in real-time