Note that there are some explanatory texts on larger screens.

plurals
  1. PORedirect standard output isn't flushed during process execution
    text
    copied!<p>I have a console application and I want to process the std out in a c# application.</p> <p>Basically I already managed to do this with this code:</p> <pre><code>Process ProcessObj = new Process(); ProcessObj.StartInfo.WorkingDirectory = WorkingPath; ProcessObj.StartInfo.FileName = ApplicationPath; ProcessObj.StartInfo.Arguments = ApplicationArguments; ProcessObj.StartInfo.UseShellExecute = false; ProcessObj.StartInfo.CreateNoWindow = true; ProcessObj.StartInfo.RedirectStandardOutput = true; // Start the process ProcessObj.Start(); // loop through until the job is done bool stopper = false; while (!stopper) { stopper = ProcessObj.WaitForExit(100); string line = null; // handle normal outputs (loop through the lines) while (true) { line = ProcessObj.StandardOutput.ReadLine(); if (line == null) break; Logger.Trace("Out: \"" + line + "\""); } } </code></pre> <p>When the process runs only a few seconds it looks like the whole thing is working without any problem. When I change the configuration of the console application to calculate more, it comes that the process is running for hours. In this time my C# application gets no response from the console app. Since the console app is hidden it looks like the app stucked but that's not true. It is already running in the background and it seems that all std outputs are only piped through to my c# app when the console app was finished the execution. So the problem is, I don't see the std out lines live in my c# app. It will be refreshed after hours when the console app has finished.</p> <p>Is there any way to flush this std out redirection? Anybody knows why this isn't working like I want?</p> <p>PS: When I execute the console app as standalone in a normal cmd window the outputs are shown live without any problem.</p> <p>Please help.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload