ITaskManager.cs 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  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. void CancelIfRunningAndQueue<T>()
  19. where T : IScheduledTask;
  20. /// <summary>
  21. /// Cancels if running.
  22. /// </summary>
  23. /// <typeparam name="T"></typeparam>
  24. void CancelIfRunning<T>()
  25. where T : IScheduledTask;
  26. /// <summary>
  27. /// Queues the scheduled task.
  28. /// </summary>
  29. /// <typeparam name="T"></typeparam>
  30. void QueueScheduledTask<T>()
  31. where T : IScheduledTask;
  32. /// <summary>
  33. /// Queues the scheduled task.
  34. /// </summary>
  35. /// <param name="task">The task.</param>
  36. void QueueScheduledTask(IScheduledTask task);
  37. /// <summary>
  38. /// Adds the tasks.
  39. /// </summary>
  40. /// <param name="tasks">The tasks.</param>
  41. void AddTasks(IEnumerable<IScheduledTask> tasks);
  42. void Cancel(IScheduledTaskWorker task);
  43. Task Execute(IScheduledTaskWorker task);
  44. event EventHandler<GenericEventArgs<IScheduledTaskWorker>> TaskExecuting;
  45. event EventHandler<TaskCompletionEventArgs> TaskCompleted;
  46. }
  47. }