ITaskManager.cs 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. using MediaBrowser.Model.Events;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Threading.Tasks;
  5. namespace MediaBrowser.Common.ScheduledTasks
  6. {
  7. public interface ITaskManager : IDisposable
  8. {
  9. /// <summary>
  10. /// Gets the list of Scheduled Tasks
  11. /// </summary>
  12. /// <value>The scheduled tasks.</value>
  13. IScheduledTaskWorker[] ScheduledTasks { get; }
  14. /// <summary>
  15. /// Cancels if running and queue.
  16. /// </summary>
  17. /// <typeparam name="T"></typeparam>
  18. /// <param name="options">Task options.</param>
  19. void CancelIfRunningAndQueue<T>(TaskExecutionOptions options = null)
  20. where T : IScheduledTask;
  21. /// <summary>
  22. /// Cancels if running.
  23. /// </summary>
  24. /// <typeparam name="T"></typeparam>
  25. void CancelIfRunning<T>()
  26. where T : IScheduledTask;
  27. /// <summary>
  28. /// Queues the scheduled task.
  29. /// </summary>
  30. /// <typeparam name="T"></typeparam>
  31. /// <param name="options">Task options.</param>
  32. void QueueScheduledTask<T>(TaskExecutionOptions options = null)
  33. where T : IScheduledTask;
  34. /// <summary>
  35. /// Queues the scheduled task.
  36. /// </summary>
  37. /// <param name="task">The task.</param>
  38. /// <param name="options">The task run options.</param>
  39. void QueueScheduledTask(IScheduledTask task, TaskExecutionOptions options = null);
  40. /// <summary>
  41. /// Adds the tasks.
  42. /// </summary>
  43. /// <param name="tasks">The tasks.</param>
  44. void AddTasks(IEnumerable<IScheduledTask> tasks);
  45. void Cancel(IScheduledTaskWorker task);
  46. Task Execute(IScheduledTaskWorker task, TaskExecutionOptions options = null);
  47. event EventHandler<GenericEventArgs<IScheduledTaskWorker>> TaskExecuting;
  48. event EventHandler<TaskCompletionEventArgs> TaskCompleted;
  49. }
  50. }