private void ExecuteAction(Shows.Action action) { ScheduleExecutor.Logging.Info("ExecuteAction: " + action.ShowItem.Name); if (State != StateType.Waiting) { ScheduleExecutor.Logging.Info("ExecuteAction: State != StateType.Waiting"); if (!action.PreProcessingCompleted) { ScheduleExecutor.AddSchedulerLogEntry(Show.Name, "Pre-processing action: " + action.ShowItem.Name); // Do this in a task so we don't stop Vixen while pre-processing! tokenSourcePreProcess = new CancellationTokenSource(); Task preProcessTask = new Task(() => action.PreProcess(), tokenSourcePreProcess.Token); preProcessTask.ContinueWith(task => { ScheduleExecutor.AddSchedulerLogEntry(Show.Name, "Starting action: " + action.ShowItem.Name); action.Execute(); RunningActions.Add(action); } ); preProcessTask.Start(); } else { ScheduleExecutor.AddSchedulerLogEntry(Show.Name, "Starting action: " + action.ShowItem.Name); action.Execute(); RunningActions.Add(action); } } }