public void ExecuteBackgroundAction(Shows.Action action) { if (State == StateType.Running) { action.ActionComplete += OnBackgroundActionComplete; ExecuteAction(action); } }
public void OnShutdownActionComplete(object sender, EventArgs e) { Shows.Action action = (sender as Shows.Action); action.ActionComplete -= OnShutdownActionComplete; lock (_actionLock) { RunningActions.Remove(action); } ScheduleExecutor.AddSchedulerLogEntry(Show.Name, "Shutdown action complete: " + action.ShowItem.Name); ExecuteNextShutdownItem(); }
private void StopSequential() { foreach (ShowItem item in Show.GetItems(ShowItemType.Sequential)) { Shows.Action action = item.GetAction(); if (action.IsRunning) { action.Stop(); } action.Dispose(); } }
public void BeginBackground() { if (Show != null) { foreach (ShowItem item in Show.GetItems(ShowItemType.Background)) { Shows.Action action = item.GetAction(); BackgroundActions.Add(action); ExecuteBackgroundAction(action); } } }
public void OnSequentialActionComplete(object sender, EventArgs e) { Shows.Action action = (sender as Shows.Action); action.ActionComplete -= OnSequentialActionComplete; lock (_actionLock) { RunningActions.Remove(action); } ScheduleExecutor.AddSchedulerLogEntry(Show.Name, "Sequential action complete: " + action.ShowItem.Name); if (!StartShutdownIfRequested()) { LogScheduleInfoEntry("OnSequentialActionComplete: Shutdown was NOT requested"); ExecuteNextSequentialItem(); } }
public void OnBackgroundActionComplete(object sender, EventArgs e) { Shows.Action action = (sender as Shows.Action); action.ActionComplete -= OnBackgroundActionComplete; lock (_actionLock) { RunningActions.Remove(action); } ScheduleExecutor.AddSchedulerLogEntry(Show.Name, "Background action complete: " + action.ShowItem.Name); // Run it again and again and again and again and again and again and again and... if (!CheckForShutdown()) { ExecuteBackgroundAction(action); } }
public void ExecuteNextShutdownItem() { if (ItemQueue.Any()) { _currentItem = ItemQueue.Dequeue(); Shows.Action action = _currentItem.GetAction(); action.ActionComplete += OnShutdownActionComplete; ExecuteAction(action); // Otherwise, the show is done :( } else { State = StateType.Waiting; ScheduleExecutor.AddSchedulerLogEntry(Show.Name, "Show complete"); Show.ReleaseAllActions(); } }
public void ExecuteNextStartupItem() { if (State == StateType.Running) { // Do we have startup items to run? if (ItemQueue.Any()) { _currentItem = ItemQueue.Dequeue(); Shows.Action action = _currentItem.GetAction(); action.ActionComplete += OnStartupActionComplete; ExecuteAction(action); } // Otherwise, move on to the sequential and background items else { BeginSequential(); BeginBackground(); } } }
public void ExecuteNextSequentialItem() { LogScheduleInfoEntry("ExecuteNextSequentialItem"); if (State == StateType.Running) { if (ItemQueue.Any()) { LogScheduleInfoEntry("ExecuteNextSequentialItem: Dequeue next item"); _currentItem = ItemQueue.Dequeue(); Shows.Action action = _currentItem.GetAction(); action.ActionComplete += OnSequentialActionComplete; ExecuteAction(action); } else { LogScheduleInfoEntry("ExecuteNextSequentialItem: Nothing left in the queue. Restarting the queue."); // Restart the queue BeginSequential(); } } }
private void ExecuteAction(Shows.Action action) { LogScheduleInfoEntry(string.Format("ExecuteAction: {0} with state of {1}", action.ShowItem.Name, State)); if (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(); lock (_actionLock) { RunningActions.Add(action); } } ); preProcessTask.Start(); } else { ScheduleExecutor.AddSchedulerLogEntry(Show.Name, "Starting action: " + action.ShowItem.Name); action.Execute(); lock (_actionLock) { RunningActions.Add(action); } } } }