예제 #1
0
 private void DoRun()
 {
     m_reportEnv.OnStart();
     using (var ub = new UsageBuilder("process"))
     {
         try
         {
             try
             {
                 SetState(ProcessState.Running);
                 ProcessRegister.OnStartedProcess(this);
                 Logging.Debug("Starting process {0}", Title);
                 this.LogMessage("s_process", LogLevel.Info, Texts.Get("s_process_started"));
                 Run();
                 this.LogMessage("s_process", LogLevel.Info, Texts.Get("s_process_finished"));
                 SetState(ProcessState.Finished);
                 Logging.Debug("Process {0} finished succesfully", Title);
             }
             finally
             {
                 m_curWork = "s_finished";
                 HProcess.CallFinishedProcess(this);
                 m_finished   = DateTime.Now;
                 ub["result"] = "ok";
             }
         }
         catch (Exception e)
         {
             m_failError = e;
             this.LogError(e);
             //this.LogMessage("s_process", LogLevel.Error, Errors.ExtractMessage(e));
             this.LogMessage("s_process", LogLevel.Error, Texts.Get("s_process_failed"));
             Logging.Error("Error when running process {0}, process finished abnormally", Title);
             SetState(ProcessState.Error_Finished);
             ub["result"] = "error";
             ub["error"]  = e.Message;
             //Errors.Report(e);
         }
     }
     if (OnFinish != null)
     {
         OnFinish();
     }
     m_reportEnv.OnFinish();
     m_reportEnv.Dispose();
 }
예제 #2
0
 public static void RemoveBackgroundTask(string title)
 {
     lock (m_bgTasks) m_bgTasks.Remove(title);
     HProcess.CallBgTasksChanged();
 }
예제 #3
0
 public static void OnStartedProcess(Process proc)
 {
     lock (m_processes) m_processes.Insert(0, proc);
     HProcess.CallStartedProcess(proc);
 }
예제 #4
0
 private void Changed()
 {
     HProcess.CallChangedProcess(this);
 }