ITaskManager.cs 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. #pragma warning disable CS1591
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Threading.Tasks;
  5. using Jellyfin.Data.Events;
  6. namespace MediaBrowser.Model.Tasks
  7. {
  8. public interface ITaskManager : IDisposable
  9. {
  10. event EventHandler<GenericEventArgs<IScheduledTaskWorker>> TaskExecuting;
  11. event EventHandler<TaskCompletionEventArgs> TaskCompleted;
  12. /// <summary>
  13. /// Gets the list of Scheduled Tasks.
  14. /// </summary>
  15. /// <value>The scheduled tasks.</value>
  16. IScheduledTaskWorker[] ScheduledTasks { get; }
  17. /// <summary>
  18. /// Cancels if running and queue.
  19. /// </summary>
  20. /// <typeparam name="T">An implementatin of <see cref="IScheduledTask" />.</typeparam>
  21. /// <param name="options">Task options.</param>
  22. void CancelIfRunningAndQueue<T>(TaskOptions options)
  23. where T : IScheduledTask;
  24. /// <summary>
  25. /// Cancels if running and queue.
  26. /// </summary>
  27. /// <typeparam name="T">An implementatin of <see cref="IScheduledTask" />.</typeparam>
  28. void CancelIfRunningAndQueue<T>()
  29. where T : IScheduledTask;
  30. /// <summary>
  31. /// Cancels if running.
  32. /// </summary>
  33. /// <typeparam name="T">An implementatin of <see cref="IScheduledTask" />.</typeparam>
  34. void CancelIfRunning<T>()
  35. where T : IScheduledTask;
  36. /// <summary>
  37. /// Queues the scheduled task.
  38. /// </summary>
  39. /// <typeparam name="T">An implementatin of <see cref="IScheduledTask" />.</typeparam>
  40. /// <param name="options">Task options.</param>
  41. void QueueScheduledTask<T>(TaskOptions options)
  42. where T : IScheduledTask;
  43. /// <summary>
  44. /// Queues the scheduled task.
  45. /// </summary>
  46. /// <typeparam name="T">An implementatin of <see cref="IScheduledTask" />.</typeparam>
  47. void QueueScheduledTask<T>()
  48. where T : IScheduledTask;
  49. void QueueIfNotRunning<T>()
  50. where T : IScheduledTask;
  51. /// <summary>
  52. /// Queues the scheduled task.
  53. /// </summary>
  54. /// <param name="task">The <see cref="IScheduledTask" /> to queue.</param>
  55. /// <param name="options">The <see cref="TaskOptions" /> to use.</param>
  56. void QueueScheduledTask(IScheduledTask task, TaskOptions options);
  57. /// <summary>
  58. /// Adds the tasks.
  59. /// </summary>
  60. /// <param name="tasks">The tasks.</param>
  61. void AddTasks(IEnumerable<IScheduledTask> tasks);
  62. void Cancel(IScheduledTaskWorker task);
  63. Task Execute(IScheduledTaskWorker task, TaskOptions options);
  64. void Execute<T>()
  65. where T : IScheduledTask;
  66. }
  67. }