Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>A variation of this works for me --posting this now because I wish I'd found it earlier. Note that this is just a fragment extracted from the real code so there may be trivial errors.</p> <p>The technique is based on some MSDN code. What I haven't been able to figure out is how to get the output window to update "on the fly". It doesn't update until after this task returns.</p> <pre><code>// Set this to your output window Pane private EnvDTE.OutputWindowPane _OutputPane = null; // Methods to receive standard output and standard error private static void StandardOutputReceiver(object sendingProcess, DataReceivedEventArgs outLine) { // Receives the child process' standard output if (! string.IsNullOrEmpty(outLine.Data)) { if (_OutputPane != null) _OutputPane.Write(outLine.Data + Environment.NewLine); } } private static void StandardErrorReceiver(object sendingProcess, DataReceivedEventArgs errLine) { // Receives the child process' standard error if (! string.IsNullOrEmpty(errLine.Data)) { if (_OutputPane != null) _OutputPane.Write("Error&gt; " + errLine.Data + Environment.NewLine); } } // main code fragment { // Start the new process ProcessStartInfo startInfo = new ProcessStartInfo(PROGRAM.EXE); startInfo.Arguments = COMMANDLINE; startInfo.WorkingDirectory = srcDir; startInfo.UseShellExecute = false; startInfo.RedirectStandardOutput = true; startInfo.RedirectStandardError = true; startInfo.CreateNoWindow = true; Process p = Process.Start(startInfo); p.OutputDataReceived += new DataReceivedEventHandler(StandardOutputReceiver); p.BeginOutputReadLine(); p.ErrorDataReceived += new DataReceivedEventHandler(StandardErrorReceiver); p.BeginErrorReadLine(); bool completed = p.WaitForExit(20000); if (!completed) { // do something here if it didn't finish in 20 seconds } p.Close(); } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

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