protected int ReadStdOutput(Process proc, out string output, out string error)
        {
            ReadAsync reader = new ReadAsync(ReadALine);
            bool      bDone  = false;

            output = string.Empty;
            error  = string.Empty;

            int result = 1;

            while (!bDone)
            {
                IAsyncResult aresult = reader.BeginInvoke(proc.StandardOutput, null, null);

                int    initWait    = Environment.TickCount;
                double totSeconds  = GetTotalProcessorTime(proc);
                int    lastElapsed = Environment.TickCount;

                while (!aresult.IsCompleted)
                {
                    result = RunWait(
                        proc, initWait,
                        ref lastElapsed,
                        ref totSeconds,
                        out error);
                    if (result != 0)
                    {
                        return(result);
                    }
                }

                string line = reader.EndInvoke(aresult);

                if (line.StartsWith(COMMAND_RESULT))
                {
                    bDone  = true;
                    result = Convert.ToInt32(line.Substring(COMMAND_RESULT.Length + 1));
                }
                else
                {
                    output += line + "\n";
                }
            }
            return(result);
        }
        protected int ReadStdOutput(Process proc, out string output, out string error)
        {
            ReadAsync reader = new ReadAsync(ReadALine);
            bool bDone = false;

            output = string.Empty;
            error = string.Empty;

            int result = 1;

            while (!bDone)
            {
                IAsyncResult aresult = reader.BeginInvoke(proc.StandardOutput, null, null);

                int initWait = Environment.TickCount;
                double totSeconds = GetTotalProcessorTime(proc);
                int lastElapsed = Environment.TickCount;

                while (!aresult.IsCompleted)
                {
                    result = RunWait(
                        proc, initWait,
                        ref lastElapsed,
                        ref totSeconds,
                        out error);
                    if (result != 0)
                        return result;
                }

                string line = reader.EndInvoke(aresult);

                if (line.StartsWith(COMMAND_RESULT))
                {
                    bDone = true;
                    result = Convert.ToInt32(line.Substring(COMMAND_RESULT.Length + 1));
                }
                else
                    output += line + "\n";
            }
            return result;
        }