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

  • Home
  • SEARCH
  • 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 7431545
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T09:18:44+00:00 2026-05-29T09:18:44+00:00

I am currently having issues redirecting both STDError and STDOutput. What I want to

  • 0

I am currently having issues redirecting both STDError and STDOutput. What I want to do is when there is an error to be printed to a rich text box along with normal output if no error is thrown.

The issue I am having is that if I add the line to redirect the SDT Error:

string error = process1.StandardError.ReadToEnd();
rchsdtOut.Text = error;

Then my normal STD Out doesn’t redirect to the text fild, but if there is an error that is printed.

process1 = new System.Diagnostics.Process();
process1.StartInfo.UseShellExecute = false;
process1.StartInfo.RedirectStandardOutput = true;
process1.StartInfo.RedirectStandardError = true;
process1.StartInfo.CreateNoWindow = true;
process1.StartInfo.FileName = "java.exe ";

//String abc = txtSingleBar.Text.Replace("\\", "/");
toLoad = lstBarToLoad.Items[i].Text;

 process1.StartInfo.Arguments = "-Xmx512M -jar";
 process1.StartInfo.Arguments += toLoad;

Console.WriteLine(process1.StartInfo.Arguments);
 try
  {
    process1.Start();      
    process1.OutputDataReceived += (s, a) => myMethod(a);
    process1.BeginOutputReadLine();

    string error = process1.StandardError.ReadToEnd();
    rchsdtOut.Text = error;
 }

Method to write events to a text fild

private void myMethod(DataReceivedEventArgs e)
{
    if (e.Data != null)
    {
        Action action = () => rchsdtOut.Text += "\r\n" + e.Data.ToString();
        rchsdtOut.BeginInvoke(action, null);
        Console.WriteLine(e.Data.ToString());
    }

}//end of private

Bascally what I want is both to be redirected, SDTOut and SDTError if one should occur.

Any ideas?

  • 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-29T09:18:45+00:00Added an answer on May 29, 2026 at 9:18 am

    Why not just take this:

    process1.OutputDataReceived += (s, a) => myMethod(a);
    process1.BeginOutputReadLine();
    

    and add this: (Don’t forget to add myErrorMethod!)

    process1.ErrorDataReceived += (s, a) => myErrorMethod(a);
    process1.BeginErrorReadLine();
    

    Then take out this:

    string error = process1.StandardError.ReadToEnd();
    

    and instead, do this (if you want to wait for it to end):

    process1.WaitForExit();
    

    Basically, you cannot mix synchronous and asynchronous output reads. You have to either use Begin_______ReadLine() or read the stream objects, but not both.

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

Sidebar

Related Questions

I'm currently having issues using the Vimeo framework on IE7. The first error I
Hello everyone I'm currently having 2 issues with the code below: Upon return of
I'm trying to learn C++ currently, but I'm having issues with the code below.
I am currently transitioning from VB to C# and am having some issues with
i'm currently having some issues by using the cakePHP data validation. I've tried to
We currently are having performance issues with grails. It is taking about 10 seconds
I am currently building a Facebook app but am having some issues with the
i'm currently having issues changing track information at the lock screen. I have managed
Currently I am having issues with QTimer. I am trying to make each Product
I'm currently having issues with my Facebook appliation being ported to CodeIgniter from raw

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.