Wrox Programmer Forums
Go Back   Wrox Programmer Forums > C# and C > C# 1.0 > C#
|
C# Programming questions specific to the Microsoft C# language. See also the forum Beginning Visual C# to discuss that specific Wrox book and code.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the C# section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old September 4th, 2007, 12:09 AM
Registered User
 
Join Date: Dec 2006
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Asynchronous reading to console+StreamReader

Hi,
    i am trying to send one command to console using Process.Start() method and want to read back the o/p line by line .
the code what i am using is as follows

    p = new Process();
            ProcessStartInfo psI = new ProcessStartInfo("cmd.exe");
            psI.UseShellExecute = false;
            psI.RedirectStandardInput = true;
            psI.RedirectStandardOutput = true;
            psI.RedirectStandardError = true;
            psI.CreateNoWindow = true;
            p.StartInfo = psI;
            p.Start();
            sw = p.StandardInput;
            sr = p.StandardOutput;
            err=p.StandardError;
            sw.AutoFlush = true;


            //executes the command
            sw.WriteLine("nant -f:main.xml");

            sw.Close();

            richTBoxOutput.AppendText(sr.ReadToEnd());


mu code strucked here on the red line till the command completed
and display the entire o/p simultaneously
HOw can i dispaly the o/p line by line



 
Old September 5th, 2007, 04:16 AM
Registered User
 
Join Date: Sep 2007
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I think this might be what you are looking for:

http://www.codeproject.com/cs/threads/launchprocess.asp

Regards,
Joachim





Similar Threads
Thread Thread Starter Forum Replies Last Post
Reading an integer from the console meghaljani Visual C++ 2005 0 September 1st, 2007 11:09 AM
Reading Console Input code_lover Java Basics 4 February 14th, 2007 09:08 AM
StreamReader.ReadToEnd Surre ASP.NET 1.0 and 1.1 Professional 0 March 30th, 2006 07:00 AM
C#: EOF using StreamReader shazia1 VS.NET 2002/2003 0 August 16th, 2005 04:25 AM
Streamreader question stevec VB.NET 2002/2003 Basics 1 October 10th, 2004 12:49 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.