Пример #1
0
        void Process_OutputDataReceived(object sender, DataReceivedEventArgs e)
        {
            LastLine = e.Data;
            OutputData.AppendLine(e.Data);
            Action <string> OutputLineHandler = OutputLine;

            if (OutputLineHandler != null)
            {
                EditorMainThread.Run(() => {
                    OutputLineHandler(e.Data);
                });
            }
        }
Пример #2
0
        void Process_ErrorDataReceived(object sender, DataReceivedEventArgs e)
        {
            ErrorData.AppendLine(e.Data);
            LastLine = e.Data;
            Action <string> ErrorLineHandler = ErrorLine;

            if (ErrorLineHandler != null)
            {
                EditorMainThread.Run(() => {
                    ErrorLineHandler(e.Data);
                });
            }
        }
Пример #3
0
        public void Start()
        {
            try {
                Process.Start();

                Process.BeginOutputReadLine();
                Process.BeginErrorReadLine();

                BackgroundProcessManager.Add(this);
            } catch (Exception ex) {
                string err = string.Format("Could not start process: {0}", ex.ToString());
                ErrorData.AppendLine(err);
                Action <string> ErrorLineHandler = ErrorLine;
                if (ErrorLineHandler != null)
                {
                    EditorMainThread.Run(() => {
                        ErrorLineHandler(err);
                    });
                }
            }
        }
Пример #4
0
        void Process_Exited(object sender, System.EventArgs e)
        {
            if (Process.ExitCode != 0)
            {
                ErrorData.Insert(0, string.Format("Exit code: {0}\n", Process.ExitCode));
            }

            ExitedDelegate ExitedHandler = Exited;

            if (ExitedHandler != null)
            {
                EditorMainThread.Run(() => {
                    ExitedHandler(Process.ExitCode, OutputData.ToString().Trim(), ErrorData.ToString().Trim());
                });
            }

            if (nextProcess != null)
            {
                if (Process.ExitCode == 0 || !nextStopOnError)
                {
                    nextProcess.Start();
                }
            }
        }