예제 #1
0
 /// <summary>
 /// Schedules a task.
 /// </summary>
 /// <param name="action"></param>
 /// <returns></returns>
 public TaskQueue Schedule(Action<TaskContext, CancellationToken> action)
 {
     var context = new TaskContext(this, async (q, ct) => action(q, ct));
     ScheduleInternal(context);
     return this;
 }
예제 #2
0
 /// <summary>
 /// Schedules a task.
 /// </summary>
 /// <param name="tag"></param>
 /// <param name="action"></param>
 /// <returns></returns>
 public TaskQueue Schedule(string tag, Func<TaskContext, CancellationToken, Task> action)
 {
     var context = new TaskContext(this, action, tag);
     ScheduleInternal(context);
     return this;
 }
예제 #3
0
 /// <summary>
 /// Schedules a task.
 /// </summary>
 /// <param name="tag"></param>
 /// <param name="task"></param>
 /// <returns></returns>
 public TaskQueue Schedule(string tag, Task task)
 {
     var context = new TaskContext(this, async (q, ct) => await task);
     ScheduleInternal(context);
     return this;
 }
예제 #4
0
 private void ScheduleInternal(TaskContext context)
 {
     queue.Enqueue(context);
     TaskScheduled?.Invoke(this, new TaskEventArgs(context.Tag));
     Next(cts.Token);
 }
예제 #5
0
 private void ScheduleInternal(TaskContext context)
 {
     queue.Enqueue(context);
     TaskScheduled?.Invoke(this, new TaskEventArgs(context.Tag));
     Next(cts.Token);
 }