public override void Clear(SchedulerContext <TaskInfo> context) { if (context.IsBusy) { throw new InvalidOperationException(); } while (context.Queue.Count > 0) { var task = context.Queue.Dequeue(); context.RaiseTaskCanceled(new TaskEventArgs(task)); } }
public override void Deschedule(SchedulerContext <TaskInfo> context, TaskInfo task) { var item = context.Queue.FirstOrDefault(x => x == task); if (item == null) { throw new InvalidOperationException("Not part of this queue."); } var e = new TaskCancelingEventArgs(task, true); context.RaiseTaskCanceling(e); if (e.Cancel) { context.Remove(item); var e2 = new TaskEventArgs(task); context.RaiseTaskCanceled(e2); } }