I ran into this problem creating MiniConsole specifically for this purpose.
I used your technique with
pro.EnableRaisingEvents = true; pro.OutputDataReceived +=new DataReceivedEventHandler(OnDataReceived); pro.ErrorDataReceived +=new DataReceivedEventHandler(OnDataReceived);
The strange thing is that all the output was obtained from ErrorDataReceived instead of OutputDataReceived (with valid commands).
So, I think you are missing:
pro.BeginErrorReadLine();
Also I started the process in the main thread (I have no worker) using python27.
Here is the full start:
// executable: "c:\\python27\\python.exe", arguments: "myscript.py" ProcessStartInfo startInfo = new ProcessStartInfo(executable, arguments); startInfo.CreateNoWindow = true; startInfo.UseShellExecute = false; startInfo.RedirectStandardOutput = true; startInfo.RedirectStandardError = true; startInfo.WindowStyle = ProcessWindowStyle.Hidden; startInfo.WorkingDirectory = textBoxWorkingDirectory.Text; try { Process p = new Process(); p.StartInfo = startInfo; p.EnableRaisingEvents = true; p.OutputDataReceived += new DataReceivedEventHandler(OnDataReceived); p.ErrorDataReceived += new DataReceivedEventHandler(OnDataReceived); p.Exited += new EventHandler(OnProcessExit); p.Start(); p.BeginOutputReadLine(); p.BeginErrorReadLine(); }
Romz
source share