diff options
Diffstat (limited to 'Emby.Server.Implementations/ScheduledTasks/TaskManager.cs')
| -rw-r--r-- | Emby.Server.Implementations/ScheduledTasks/TaskManager.cs | 35 |
1 files changed, 19 insertions, 16 deletions
diff --git a/Emby.Server.Implementations/ScheduledTasks/TaskManager.cs b/Emby.Server.Implementations/ScheduledTasks/TaskManager.cs index c0fcb459d..8963693ab 100644 --- a/Emby.Server.Implementations/ScheduledTasks/TaskManager.cs +++ b/Emby.Server.Implementations/ScheduledTasks/TaskManager.cs @@ -32,8 +32,8 @@ namespace Emby.Server.Implementations.ScheduledTasks /// <summary> /// The _task queue /// </summary> - private readonly ConcurrentQueue<Tuple<Type, TaskExecutionOptions>> _taskQueue = - new ConcurrentQueue<Tuple<Type, TaskExecutionOptions>>(); + private readonly ConcurrentQueue<Tuple<Type, TaskOptions>> _taskQueue = + new ConcurrentQueue<Tuple<Type, TaskOptions>>(); /// <summary> /// Gets or sets the json serializer. @@ -114,6 +114,10 @@ namespace Emby.Server.Implementations.ScheduledTasks { var path = Path.Combine(ApplicationPaths.CachePath, "startuptasks.txt"); + // ToDo: Fix this shit + if (!File.Exists(path)) + return; + List<string> lines; try @@ -126,7 +130,7 @@ namespace Emby.Server.Implementations.ScheduledTasks if (task != null) { - QueueScheduledTask(task, new TaskExecutionOptions()); + QueueScheduledTask(task, new TaskOptions()); } } @@ -143,7 +147,7 @@ namespace Emby.Server.Implementations.ScheduledTasks /// </summary> /// <typeparam name="T"></typeparam> /// <param name="options">Task options.</param> - public void CancelIfRunningAndQueue<T>(TaskExecutionOptions options) + public void CancelIfRunningAndQueue<T>(TaskOptions options) where T : IScheduledTask { var task = ScheduledTasks.First(t => t.ScheduledTask.GetType() == typeof(T)); @@ -155,7 +159,7 @@ namespace Emby.Server.Implementations.ScheduledTasks public void CancelIfRunningAndQueue<T>() where T : IScheduledTask { - CancelIfRunningAndQueue<T>(new TaskExecutionOptions()); + CancelIfRunningAndQueue<T>(new TaskOptions()); } /// <summary> @@ -174,7 +178,7 @@ namespace Emby.Server.Implementations.ScheduledTasks /// </summary> /// <typeparam name="T"></typeparam> /// <param name="options">Task options</param> - public void QueueScheduledTask<T>(TaskExecutionOptions options) + public void QueueScheduledTask<T>(TaskOptions options) where T : IScheduledTask { var scheduledTask = ScheduledTasks.FirstOrDefault(t => t.ScheduledTask.GetType() == typeof(T)); @@ -192,7 +196,7 @@ namespace Emby.Server.Implementations.ScheduledTasks public void QueueScheduledTask<T>() where T : IScheduledTask { - QueueScheduledTask<T>(new TaskExecutionOptions()); + QueueScheduledTask<T>(new TaskOptions()); } public void QueueIfNotRunning<T>() @@ -202,7 +206,7 @@ namespace Emby.Server.Implementations.ScheduledTasks if (task.State != TaskState.Running) { - QueueScheduledTask<T>(new TaskExecutionOptions()); + QueueScheduledTask<T>(new TaskOptions()); } } @@ -225,7 +229,7 @@ namespace Emby.Server.Implementations.ScheduledTasks { if (scheduledTask.State == TaskState.Idle) { - Execute(scheduledTask, new TaskExecutionOptions()); + Execute(scheduledTask, new TaskOptions()); } } } @@ -236,7 +240,7 @@ namespace Emby.Server.Implementations.ScheduledTasks /// </summary> /// <param name="task">The task.</param> /// <param name="options">The task options.</param> - public void QueueScheduledTask(IScheduledTask task, TaskExecutionOptions options) + public void QueueScheduledTask(IScheduledTask task, TaskOptions options) { var scheduledTask = ScheduledTasks.FirstOrDefault(t => t.ScheduledTask.GetType() == task.GetType()); @@ -255,7 +259,7 @@ namespace Emby.Server.Implementations.ScheduledTasks /// </summary> /// <param name="task">The task.</param> /// <param name="options">The task options.</param> - private void QueueScheduledTask(IScheduledTaskWorker task, TaskExecutionOptions options) + private void QueueScheduledTask(IScheduledTaskWorker task, TaskOptions options) { var type = task.ScheduledTask.GetType(); @@ -269,7 +273,7 @@ namespace Emby.Server.Implementations.ScheduledTasks return; } - _taskQueue.Enqueue(new Tuple<Type, TaskExecutionOptions>(type, options)); + _taskQueue.Enqueue(new Tuple<Type, TaskOptions>(type, options)); } } @@ -297,7 +301,6 @@ namespace Emby.Server.Implementations.ScheduledTasks public void Dispose() { Dispose(true); - GC.SuppressFinalize(this); } /// <summary> @@ -317,7 +320,7 @@ namespace Emby.Server.Implementations.ScheduledTasks ((ScheduledTaskWorker)task).Cancel(); } - public Task Execute(IScheduledTaskWorker task, TaskExecutionOptions options) + public Task Execute(IScheduledTaskWorker task, TaskOptions options) { return ((ScheduledTaskWorker)task).Execute(options); } @@ -362,9 +365,9 @@ namespace Emby.Server.Implementations.ScheduledTasks // Execute queued tasks lock (_taskQueue) { - var list = new List<Tuple<Type, TaskExecutionOptions>>(); + var list = new List<Tuple<Type, TaskOptions>>(); - Tuple<Type, TaskExecutionOptions> item; + Tuple<Type, TaskOptions> item; while (_taskQueue.TryDequeue(out item)) { if (list.All(i => i.Item1 != item.Item1)) |
