示例#1
0
 /// <summary>
 /// 启动程序
 /// </summary>
 public void Run()
 {
     if (this.State != ProcessState.RUNNING)
     {
         try
         {
             this.Logger.Info("{Ptilopsis_Runner}Runner Start");
             this.State   = ProcessState.RUNNING;
             this.Process = Process.Start(this.ProcessInfo);
             this.Process.OutputDataReceived += Process_OutputDataReceived;
             this.Process.ErrorDataReceived  += Process_ErrorDataReceived;
             this.Process.Exited             += Process_Exited;
             this.Process.EnableRaisingEvents = true;
             this.Process.BeginOutputReadLine();
             this.Process.BeginErrorReadLine();
         }
         catch (Exception e)
         {
             this.Logger.Error(e.ToString());
             this.Logger.Info("{Ptilopsis_Runner}Runner Error End");
             this.State = ProcessState.STOP;
             EventManager.Get().RegEvent(ptiEvent => {
                 RunnerManager.Get().RemoveRunner(this);
                 this.Dispose();
                 return(null);
             });
         }
     }
 }
示例#2
0
 private void Process_Exited(object sender, EventArgs e)
 {
     this.Logger.Info("{Ptilopsis_Runner}Runner End");
     if (this.State == ProcessState.KILLING)
     {
         this.State = ProcessState.KILLED;
     }
     else
     {
         this.State = ProcessState.STOP;
     }
     EventManager.Get().RegEvent(ptiEvent => {
         RunnerManager.Get().RemoveRunner(this);
         this.Dispose();
         return(null);
     });
 }