public void Commit(ExecutorStatus Status, DateTime EndTime, String Description = "") //Need to check the Executor Status to make sure it is executing { if (Status != ExecutorStatus.Completed && Status != ExecutorStatus.Invalid) { System.Windows.MessageBox.Show("Only Completed and Invalid are available status to be commited"); return; } if (this.Status == ExecutorStatus.Executing) { this.Description = Description; this.EndTime = EndTime; if (Chamber != null) { Chamber.Status = AssetStatusEnum.IDLE; Chamber.UpdateRecords(StartTime, Chamber.Status); } TesterChannel.Status = AssetStatusEnum.IDLE; TesterChannel.UpdateRecords(StartTime, TesterChannel.Status); Battery.Status = AssetStatusEnum.IDLE; Battery.UpdateRecords(StartTime, Battery.Status); this.Status = Status; //this has to be the last assignment because it will raise StatusChanged event so that duration will be updated using StartTime and EndTime } else { System.Windows.MessageBox.Show("Only executing tasks can be commited!"); } }
private RunStatus MapRunStatus(ExecutorStatus status) { switch (status) { case ExecutorStatus.NotStarted: return(RunStatus.NotStarted); case ExecutorStatus.Running: return(RunStatus.Running); case ExecutorStatus.Canceled: return(RunStatus.Canceled); case ExecutorStatus.Completed: return(RunStatus.Completed); default: throw new NotSupportedException($"Unknown ExecutorStatus {status}"); } }
private async void Loop() { Status = ExecutorStatus.Running; while (await queue.OutputAvailableAsync()) { InputParameters tmp = queue.Receive(); semaphore.WaitOne(); Action taskingOperation = () => { if (tmp.CallBack != null) { string id = Guid.NewGuid().ToString(); var path = ArgumentsToFiles(tmp.Parameters, tmp.ScriptSource, id); try { OperationRun(path); string[] result = FilesToOutputs(path); tmp.CallBack(result); } catch (Exception ex) { Console.Error.WriteLine(ex.Message); tmp.CallBack(null); } Directory.Delete(path, true); } semaphore.Release(); }; #pragma warning disable CS4014 // Так как этот вызов не ожидается, выполнение существующего метода продолжается до завершения вызова Task.Run(taskingOperation); #pragma warning restore CS4014 // Так как этот вызов не ожидается, выполнение существующего метода продолжается до завершения вызова } }
public Executor(int n) { semaphore = new Semaphore(n, n); Status = ExecutorStatus.Idle; Loop(); }
public StatusEventArgs(ExecutorStatus status, decimal percentage) { Status = status; Percentage = percentage; }