C # standardoutput redirection

Source: Internet
Author: User

From: http://bbs.csdn.net/topics/190051920#new_post

This. Process = new process ();
This. process. startinfo. createnowindow = true;
This. process. startinfo. useshellexecute = false;
This. process. startinfo. filename = filename;
This. process. startinfo. redirectstandarderror = false;
This. process. startinfo. redirectstandardinput = true;
This. process. startinfo. redirectstandardoutput = true;
This. process. Start ();
Streamwriter Sw = This. process. standardinput;
Sw. Write (test );
Sw. Close ();
String output = This. process. standardoutput. readtoend ();
This. process. waitforexit ();
This. process. Close ();
The variables such as test and filename are defined previously.
The problem is:
When I output 1000 rows, it is completely normal.
However, when the output behavior is 2000 or above, it will be blocked.

That is, when too many inputs are input
String output = This. process. standardoutput. readtoend ();
The program will block the above line

Please help
Provide a solution
I am very grateful.

Add
Is too many output

That is, I know that there will be a lot of output (usually more than 1000 rows)
It will block

I thought too many inputs.
I put
This. process. startinfo. redirectstandardoutput = true;
The
This. process. startinfo. redirectstandardoutput = false;
Hour
No matter how much test data is input
All programs are normal

Is there a size limit for standardoutput?
If
Thank you.

I understand all this.
I said it works normally when there is little data.
Not completely running

A problem still found
If the input exceeds several thousand rows
Blocking will also occur.

Thank you.
(Again, I have successfully run it, that is, a problem occurs when there are too many data inputs or outputs ......)

 

The buffer is indeed limited in size, and if the buffer is full, the system will block waiting for the buffer to discharge appropriate data.
The solution is to output the data in the buffer to a certain place before the buffer is full.
In addition, a workaround method is to use a redirection symbol (>,>> to replace it by calling a batch file.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.