Exemplo n.º 1
0
 public virtual void Run()
 {
     hasStarted = true;
     status.SendMessage("Beginning process: " + process.StartInfo.FileName + " with arguments " + process.StartInfo.Arguments);
     runningThread = new Thread(delegate() { RunProcess(status); });
     runningThread.Start();
 }
Exemplo n.º 2
0
        public int RunProcess(PipelineStatus status)
        {
            try
            {
                process.Start();

                // do not wait for the child process to exit before
                // reading to the end of its redirected stream.
                // process.WaitForExit();

                // read the output stream first and then wait.
                //output = process.StandardOutput.ReadToEnd();
                //Debug.Log(output);
                process.BeginOutputReadLine();
                process.BeginErrorReadLine();
                process.WaitForExit();
                exitCode = process.ExitCode;
            }
            catch (ThreadAbortException e)
            {
                process.Kill();
                status.SendMessage("Process exited by user");
            }
            catch (System.Exception e)
            {
                status.SendErrorMessage("Run error" + e.ToString()); // or throw new Exception
                exitCode = process.ExitCode;
            }
            finally
            {
                status.SendMessage("Process finished with exit code " + exitCode);
                process.Dispose();
                hasFinished = true;
                process     = null;
            }
            return(exitCode);
        }