ITaskManager.cs 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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)
  20. where T : IScheduledTask;
  21. /// <summary>
  22. /// Cancels if running and queue.
  23. /// </summary>
  24. /// <typeparam name="T"></typeparam>
  25. void CancelIfRunningAndQueue<T>()
  26. where T : IScheduledTask;
  27. /// <summary>
  28. /// Cancels if running.
  29. /// </summary>
  30. /// <typeparam name="T"></typeparam>
  31. void CancelIfRunning<T>()
  32. where T : IScheduledTask;
  33. /// <summary>
  34. /// Queues the scheduled task.
  35. /// </summary>
  36. /// <typeparam name="T"></typeparam>
  37. /// <param name="options">Task options.</param>
  38. void QueueScheduledTask<T>(TaskExecutionOptions options)
  39. where T : IScheduledTask;
  40. /// <summary>
  41. /// Queues the scheduled task.
  42. /// </summary>
  43. /// <typeparam name="T"></typeparam>
  44. void QueueScheduledTask<T>()
  45. where T : IScheduledTask;
  46. void QueueIfNotRunning<T>()
  47. where T : IScheduledTask;
  48. /// <summary>
  49. /// Queues the scheduled task.
  50. /// </summary>
  51. /// <param name="task">The task.</param>
  52. /// <param name="options">The task run options.</param>
  53. void QueueScheduledTask(IScheduledTask task, TaskExecutionOptions options = null);
  54. /// <summary>
  55. /// Adds the tasks.
  56. /// </summary>
  57. /// <param name="tasks">The tasks.</param>
  58. void AddTasks(IEnumerable<IScheduledTask> tasks);
  59. void Cancel(IScheduledTaskWorker task);
  60. Task Execute(IScheduledTaskWorker task, TaskExecutionOptions options = null);
  61. void Execute<T>()
  62. where T : IScheduledTask;
  63. event EventHandler<GenericEventArgs<IScheduledTaskWorker>> TaskExecuting;
  64. event EventHandler<TaskCompletionEventArgs> TaskCompleted;
  65. bool SuspendTriggers { get; set; }
  66. }
  67. }