Note that there are some explanatory texts on larger screens.

plurals
  1. POCalling executable using Process crashes intermittently
    text
    copied!<p>I am calling an executable in C#. When the executable runs, it writes out to the console so the C# code is getting the console output and writing it to a text file. When the crash happens a couple of things occur.</p> <p>1) The output of the text file is not completely written out. 2) The executable process seems to run completely through because it generates a report just like a successful run.</p> <p>I suspect that the reason for this crash is because of how I'm writing the file out.</p> <p>Update: - As far as the crash, a dialog comes up saying that the "Manager has encountered a problem and needs to close. We are sorry for the inconvenience." Then it has an OK button. When you click OK, there is a dialog that I have setup that asks if I want to start the manager again.</p> <ul> <li>The manager application that is calling the executable is single threaded. The executable may run multi-threaded.</li> </ul> <p>Here is a small snippet of the call:</p> <pre><code> // Set up process to redirect standard output and standard error to // a file. process.StartInfo.UseShellExecute = false; process.StartInfo.RedirectStandardOutput = true; process.StartInfo.RedirectStandardError = true; FileInfo ofi = new FileInfo(outputPath); FileStream ofs = ofi.OpenWrite(); StreamWriter sw = new StreamWriter(ofs); WriteToTextWriterEventHandler wtsweh = new WriteToTextWriterEventHandler(sw); DataReceivedEventHandler handler = wtsweh.HandleDataReceived; process.OutputDataReceived += handler; process.ErrorDataReceived += handler; // statusAcceptor.ReportStatus("Running process."); process.Start(); process.BeginOutputReadLine(); process.BeginErrorReadLine(); statusAcceptor.ReportStatus("Waiting for process to complete."); process.WaitForExit(); int processExitCode = process.ExitCode; process.Close(); sw.Close(); // private class WriteToTextWriterEventHandler { private TextWriter tw; public WriteToTextWriterEventHandler(TextWriter tw) { this.tw = tw; } public void HandleDataReceived(object sendingProcess, DataReceivedEventArgs outLine) { // Collect the sort command output. if (!String.IsNullOrEmpty(outLine.Data)) { tw.Write(Environment.NewLine + outLine.Data); } } } </code></pre>
 

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