コード例 #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);
 }