StandardOutput.EndOfStream Hangs

前端 未结 4 911
情书的邮戳
情书的邮戳 2020-12-20 23:21

I\'m starting a process within my C# application which runs a console application. I\'ve redirected standard input and output, and am able to read a few lines via StandardO

4条回答
  •  没有蜡笔的小新
    2020-12-20 23:43

    If you know that there is no more standard input after your:

    while (!mProcess.StandardOutput.EndOfStream) 
    

    loop, you can close standard input with:

    mProcess.StandardInput.Close();
    

    To signal that there is no more input. As long as standard input is open, there is the potential for more input, thus more output; therefore, standard output will never reach EndOfStream.

提交回复
热议问题