2020-02-03 17:49:27 -07:00
|
|
|
#pragma warning disable CS1591
|
|
|
|
|
2019-01-13 13:02:23 -07:00
|
|
|
using System;
|
2018-12-27 16:27:57 -07:00
|
|
|
using System.Collections.Generic;
|
|
|
|
using System.Threading.Tasks;
|
2020-08-13 17:48:28 -07:00
|
|
|
using Jellyfin.Data.Events;
|
2018-12-27 16:27:57 -07:00
|
|
|
|
|
|
|
namespace MediaBrowser.Model.Tasks
|
|
|
|
{
|
|
|
|
public interface ITaskManager : IDisposable
|
|
|
|
{
|
2023-02-15 15:41:28 -07:00
|
|
|
event EventHandler<GenericEventArgs<IScheduledTaskWorker>>? TaskExecuting;
|
2021-02-20 15:13:04 -07:00
|
|
|
|
2023-02-15 15:41:28 -07:00
|
|
|
event EventHandler<TaskCompletionEventArgs>? TaskCompleted;
|
2021-02-20 15:13:04 -07:00
|
|
|
|
2018-12-27 16:27:57 -07:00
|
|
|
/// <summary>
|
2020-06-15 15:37:52 -07:00
|
|
|
/// Gets the list of Scheduled Tasks.
|
2018-12-27 16:27:57 -07:00
|
|
|
/// </summary>
|
|
|
|
/// <value>The scheduled tasks.</value>
|
|
|
|
IScheduledTaskWorker[] ScheduledTasks { get; }
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Cancels if running and queue.
|
|
|
|
/// </summary>
|
2022-08-15 03:48:34 -07:00
|
|
|
/// <typeparam name="T">An implementation of <see cref="IScheduledTask" />.</typeparam>
|
2018-12-27 16:27:57 -07:00
|
|
|
/// <param name="options">Task options.</param>
|
|
|
|
void CancelIfRunningAndQueue<T>(TaskOptions options)
|
|
|
|
where T : IScheduledTask;
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Cancels if running and queue.
|
|
|
|
/// </summary>
|
2022-08-15 03:48:34 -07:00
|
|
|
/// <typeparam name="T">An implementation of <see cref="IScheduledTask" />.</typeparam>
|
2018-12-27 16:27:57 -07:00
|
|
|
void CancelIfRunningAndQueue<T>()
|
|
|
|
where T : IScheduledTask;
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Cancels if running.
|
|
|
|
/// </summary>
|
2022-08-15 03:48:34 -07:00
|
|
|
/// <typeparam name="T">An implementation of <see cref="IScheduledTask" />.</typeparam>
|
2018-12-27 16:27:57 -07:00
|
|
|
void CancelIfRunning<T>()
|
|
|
|
where T : IScheduledTask;
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Queues the scheduled task.
|
|
|
|
/// </summary>
|
2022-08-15 03:48:34 -07:00
|
|
|
/// <typeparam name="T">An implementation of <see cref="IScheduledTask" />.</typeparam>
|
2018-12-27 16:27:57 -07:00
|
|
|
/// <param name="options">Task options.</param>
|
|
|
|
void QueueScheduledTask<T>(TaskOptions options)
|
|
|
|
where T : IScheduledTask;
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Queues the scheduled task.
|
|
|
|
/// </summary>
|
2022-08-15 03:48:34 -07:00
|
|
|
/// <typeparam name="T">An implementation of <see cref="IScheduledTask" />.</typeparam>
|
2018-12-27 16:27:57 -07:00
|
|
|
void QueueScheduledTask<T>()
|
|
|
|
where T : IScheduledTask;
|
|
|
|
|
|
|
|
void QueueIfNotRunning<T>()
|
|
|
|
where T : IScheduledTask;
|
2019-01-07 16:27:46 -07:00
|
|
|
|
2018-12-27 16:27:57 -07:00
|
|
|
/// <summary>
|
|
|
|
/// Queues the scheduled task.
|
|
|
|
/// </summary>
|
2021-02-20 15:13:04 -07:00
|
|
|
/// <param name="task">The <see cref="IScheduledTask" /> to queue.</param>
|
|
|
|
/// <param name="options">The <see cref="TaskOptions" /> to use.</param>
|
2018-12-27 16:27:57 -07:00
|
|
|
void QueueScheduledTask(IScheduledTask task, TaskOptions options);
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Adds the tasks.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="tasks">The tasks.</param>
|
|
|
|
void AddTasks(IEnumerable<IScheduledTask> tasks);
|
|
|
|
|
|
|
|
void Cancel(IScheduledTaskWorker task);
|
2021-02-20 15:13:04 -07:00
|
|
|
|
2018-12-27 16:27:57 -07:00
|
|
|
Task Execute(IScheduledTaskWorker task, TaskOptions options);
|
|
|
|
|
|
|
|
void Execute<T>()
|
|
|
|
where T : IScheduledTask;
|
|
|
|
}
|
2019-01-13 12:31:15 -07:00
|
|
|
}
|