Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6722977
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T09:30:47+00:00 2026-05-26T09:30:47+00:00

Is it possible to receive the output from System.Diagnostic.Process when..occur and not at the

  • 0

Is it possible to receive the output from System.Diagnostic.Process when..occur and not at the end of line ?
At the moment, i have

    psi.RedirectStandardOutput = true;
    psi.RedirectStandardError = true;
    psi.WindowStyle = System.Diagnostics.ProcessWindowStyle.Normal;
    psi.UseShellExecute = false;

    reg = System.Diagnostics.Process.Start(psi);

    reg.OutputDataReceived += new DataReceivedEventHandler(SortOutputHandler);
    reg.BeginOutputReadLine();  

As you can see, a call to BeginOutputReadLine allow me to read the (redirected) output only when an end line is found.
Does exists the same method but that call the delegate “when the process send any char to output” ?

Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T09:30:48+00:00Added an answer on May 26, 2026 at 9:30 am

    It would seem that the asynchronous methods/events don’t allow you to read single characters from the output (Only complete lines, as the method names suggest).

    The following code does what you want, but in a synchronous way:

    class Program
    {
        public static bool Exit = false;
        static void Main(string[] args)
        {
            var p = new Process
                        {
                            StartInfo =
                                {
                                    FileName = @"program-not-outputting-newlines",
                                    Arguments = "test",
                                    UseShellExecute = false,
                                    RedirectStandardOutput = true
                                },
                            EnableRaisingEvents = true
                        };
            p.Start();
            var s = p.StandardOutput;
            p.Exited += (sender, e) => Exit = true;
    
            while(!Exit)
            {
                Console.Write((char) s.Read());
            }
            Console.Read();
        }
    }
    

    The call to s.Read() seems to block the current thread (Even though there is a ReadBlock() version of it — the docwriter probably misunderstood), so you might want to make that in a seperate thread and do some message passing/eventraising of your own to make it asynchronous.

    The program I tested with was a simple loop outputting integers from 0 to 10 with random intervals, without newlines in between, and calls to Console.Out.Flush for every write.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

First, the simple question. Is it possible to receive an event when MEF (System.ComponentModel.Composition)
Is it possible for a receive statement to have multiple timeout clauses, and if
I was wondering if is is possible to send output from application ran by
In Python one can say this: python script.py from the command line and receive
Is it possible to receive the output of time.time() in Python 2.5 as a
I know its possible to receive a dayClick event on Fullcalendar. But I would
I was wondering is it possible to register a broadcast receiver to receive two
C# It's possible to set to a variant this sentence {D , and receive
Can I modify the result that I have received from mysql_query than reset the
I have 2 powershell scripts that I execute from c# which I'm using to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.