Trying to get live standard out

Is there a way to get live output from another exe? It seems the output onlys comes on when I end the execution of the program or when it errors, but it when it processes information, I get zero output redirection to my textbox

snippet of my code

string standardError;

 using (var process = new Process()) { process.StartInfo = cmd; process.StartInfo.UseShellExecute = false; process.StartInfo.CreateNoWindow = true; process.StartInfo.RedirectStandardError = true; process.StartInfo.RedirectStandardOutput = true; process.StartInfo.FileName = txtWccLitePath.Text + @"\wcc_lite.exe"; process.StartInfo.WorkingDirectory = txtWccLitePath.Text; process.StartInfo.Arguments = Properties.Settings.Default.argument; process.Start(); //Thread.Sleep(100); using (Task<string> outputReader = Task.Factory.StartNew(() => process.StandardOutput.ReadToEnd())) using (Task<string> errorReader = Task.Factory.StartNew(() => process.StandardError.ReadToEnd())) { Task.WaitAll(outputReader, errorReader); txtOutPut.Text = outputReader.Result; standardError = errorReader.Result; } } 

And it seems up to this point I have tried everything even other snippets from blogs..

by dattyGiraffe via /r/csharp

Leave a Reply