/// <summary> /// Executes the task synchronously. /// This does not make use of a controller and therefore the <see cref="AppTask.ID"/> /// property will not get set. /// </summary> /// <param name="task">The task to run.</param> /// <param name="taskFolderPath"> /// The folder path to use when running this task. /// If not specified, the <see cref="Environment.CurrentDirectory"/> will be used. /// </param> public static void ExecuteTaskInline(AppTask task, string taskFolderPath = null) { if (String.IsNullOrEmpty(taskFolderPath)) { taskFolderPath = Environment.CurrentDirectory; } task.Setup(taskFolderPath); if (!task.IsComplete) // i.e. has not completed with an error during setup. { task.RunSynchronously(); } }
internal ContinuationAppTask(AppTask antecedentTask, Action <AppTask> body) { if (antecedentTask == null) { throw new ArgumentNullException("antecendantTask"); } if (body == null) { throw new ArgumentNullException("body"); } _antecedentTask = antecedentTask; _body = body; }
private void SetupTask(AppTask task) { if (task.Status > AppTaskStatus.Waiting) { throw new InvalidOperationException("The task is already setup."); } // Setup the task string taskFolderPath = task.TaskFolderPath; if (String.IsNullOrEmpty(taskFolderPath)) { taskFolderPath = Path.Combine(BaseFolderPath, String.Format(TaskFolderNameFormatString, task.ID)); } task.Setup(taskFolderPath); }
void task_StatusChanged(AppTask task, AppTaskStatusChangedEventArgs e) { switch (e.CurrentStatus) { case AppTaskStatus.Preparing: case AppTaskStatus.Setup: break; // Nothing to do case AppTaskStatus.Waiting: _waitingTasks.Enqueue(task); break; case AppTaskStatus.Starting: _executingTasks.Add(task); break; case AppTaskStatus.Running: Debug.Assert(_executingTasks.Contains(task)); OnTaskStarted(task); break; case AppTaskStatus.Complete: case AppTaskStatus.Cancelled: case AppTaskStatus.Error: if (e.PreviousStatus == AppTaskStatus.Starting || e.PreviousStatus == AppTaskStatus.Running) { _executingTasks.Remove(task); } OnTaskCompleted(task); AddContinuations(task); break; default: throw new NotImplementedException("The CurrentStatus is not handled: " + e.CurrentStatus); } }
void task_TaskSetup(AppTask task, EventArgs e) { task.SetWaiting(); }