/// <summary> /// Creates event arguments for a task-related event. /// </summary> /// <param name="task">The task that the event is about.</param> /// <exception cref="ArgumentNullException">Thrown if <paramref name="task"/> is null.</exception> public TaskEventArgs(Task task) { if (task == null) throw new ArgumentNullException("task"); this.task = task; }
private void TaskTerminated(Task workerTask, string queueId) { if (!workerTask.IsAborted && !workerTask.Result.HasValue) { ProcessFailure(workerTask.Result.Exception, queueId); } currentWorkerTasks.Write(tasks => tasks.Remove(queueId)); eventAggregator.Send(this, new TaskCompleted(queueId)); RunTask(queueId); }
private static void RecordTaskResult(TestContext context, Task task) { if (task.Result != null && ! task.Result.HasValue) { context.LogWriter.Warnings.WriteException(task.Result.Exception, String.Format("Task '{0}' failed.", task.Name)); FailureFlag = true; } }
/// <summary> /// Adds a new task for the task manager to watch. /// </summary> /// <remarks> /// <para> /// The task manager will track when the task starts and finishes, ensure /// that the task is aborted when the test ends, report any exception thrown /// by the task as a warning in the log, and include the task in the list of those /// to join and/or verify. /// </para> /// </remarks> /// <param name="task">The task to watch.</param> /// <exception cref="ArgumentNullException">Thrown if <paramref name="task"/> is null.</exception> public static void WatchTask(Task task) { if (task == null) throw new ArgumentNullException("task"); GetTaskContainer().Watch(task); }