Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Process hangs with RedirectStandardOutput

Process hangs with RedirectStandardOutput

Scheduled Pinned Locked Moved C#
helpcsharpvisual-studioworkspace
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • L Offline
    L Offline
    liqnit
    wrote on last edited by
    #1

    :( Hi I am trying to compile a workspace using Msdev.exe (Visual Studio 6) . I am using the command line and want to redirect the output into a rich textbox on my form. When an error in compilation occur the process is hanged until i stop my application and only then the Msdev is showing the error. System.IntPtr PrHndle; Process Prc = new Process(); Prc.StartInfo.FileName = VS6EXEPath; Prc.StartInfo.Arguments = WorkSpace + CompileCommandString; Prc.StartInfo.UseShellExecute = false; Prc.StartInfo.RedirectStandardOutput=true; Prc.Start(); PrHndle = Prc.Handle; StreamReader SR = Prc.StandardOutput; while (SR.EndOfStream != true) { rtbCmdOutput.Text = rtbCmdOutput.Text + "\r\n" + SR.ReadLine(); } Prc.WaitForExit(); Same code works good with appliaction. Please help:(

    Have a nice Day

    J 1 Reply Last reply
    0
    • L liqnit

      :( Hi I am trying to compile a workspace using Msdev.exe (Visual Studio 6) . I am using the command line and want to redirect the output into a rich textbox on my form. When an error in compilation occur the process is hanged until i stop my application and only then the Msdev is showing the error. System.IntPtr PrHndle; Process Prc = new Process(); Prc.StartInfo.FileName = VS6EXEPath; Prc.StartInfo.Arguments = WorkSpace + CompileCommandString; Prc.StartInfo.UseShellExecute = false; Prc.StartInfo.RedirectStandardOutput=true; Prc.Start(); PrHndle = Prc.Handle; StreamReader SR = Prc.StandardOutput; while (SR.EndOfStream != true) { rtbCmdOutput.Text = rtbCmdOutput.Text + "\r\n" + SR.ReadLine(); } Prc.WaitForExit(); Same code works good with appliaction. Please help:(

      Have a nice Day

      J Offline
      J Offline
      Judah Gabriel Himango
      wrote on last edited by
      #2

      Instead of blocking the thread waiting for output, use an event to listen for output:

      Process proc = ...;
      proc.OutputDataReceived += OutputDataReceivedHandler;

      ...
      void OutputDataReceivedHandler(object sender, System.Diagnostics.DataReceivedEventArgs e)
      {
      rtbCmdOutput.AppendText(e.Data);
      }

      Tech, life, family, faith: Give me a visit. I'm currently blogging about: Sound The Great Shofar! The apostle Paul, modernly speaking: Epistles of Paul Judah Himango

      L 1 Reply Last reply
      0
      • J Judah Gabriel Himango

        Instead of blocking the thread waiting for output, use an event to listen for output:

        Process proc = ...;
        proc.OutputDataReceived += OutputDataReceivedHandler;

        ...
        void OutputDataReceivedHandler(object sender, System.Diagnostics.DataReceivedEventArgs e)
        {
        rtbCmdOutput.AppendText(e.Data);
        }

        Tech, life, family, faith: Give me a visit. I'm currently blogging about: Sound The Great Shofar! The apostle Paul, modernly speaking: Epistles of Paul Judah Himango

        L Offline
        L Offline
        liqnit
        wrote on last edited by
        #3

        Thanks for the quick answer i will try it and post feedback

        Have a nice Day

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups