コード例 #1
0
 public void thr()
 {
     while (StandardOutput.Peek() == -1)
     {
     }
     ;
 }
コード例 #2
0
        public IEnumerable <string> GetOutput()
        {
            int    stdOutIndex   = 0;
            int    stdErrorIndex = 0;
            int    BUF_SIZE      = 4096;
            string output        = "";

            while (!HasExited)
            {
                char[] buf = new char[BUF_SIZE];
                if (StandardOutput.Peek() > -1)
                {
                    stdOutIndex += StandardOutput.Read(buf, stdOutIndex, BUF_SIZE);
                    output       = (new string(buf)).Trim();
                }
                else if (StandardError.Peek() > -1)
                {
                    stdErrorIndex += StandardError.Read(buf, stdErrorIndex, BUF_SIZE);
                    output         = (new string(buf)).Trim();
                }
                else
                {
                    output = "";
                }
                if (!string.IsNullOrEmpty(output))
                {
                    yield return(output);
                }
            }

            output = (StandardOutput.ReadToEnd().Trim() + "\r\n" + StandardError.ReadToEnd().Trim()).Trim();
            //Console.WriteLine($"Final output: {output}");
            if (!string.IsNullOrEmpty(output))
            {
                yield return(output);
            }
        }