ITaskManager.cs 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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. /// <summary>
  47. /// Queues the scheduled task.
  48. /// </summary>
  49. /// <param name="task">The task.</param>
  50. /// <param name="options">The task run options.</param>
  51. void QueueScheduledTask(IScheduledTask task, TaskExecutionOptions options = null);
  52. /// <summary>
  53. /// Adds the tasks.
  54. /// </summary>
  55. /// <param name="tasks">The tasks.</param>
  56. void AddTasks(IEnumerable<IScheduledTask> tasks);
  57. void Cancel(IScheduledTaskWorker task);
  58. Task Execute(IScheduledTaskWorker task, TaskExecutionOptions options = null);
  59. void Execute<T>()
  60. where T : IScheduledTask;
  61. event EventHandler<GenericEventArgs<IScheduledTaskWorker>> TaskExecuting;
  62. event EventHandler<TaskCompletionEventArgs> TaskCompleted;
  63. bool SuspendTriggers { get; set; }
  64. }
  65. }