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.