diff --git a/Emby.Server.Implementations/EntryPoints/ServerEventNotifier.cs b/Emby.Server.Implementations/EntryPoints/ServerEventNotifier.cs
index 0e50866851..833c061066 100644
--- a/Emby.Server.Implementations/EntryPoints/ServerEventNotifier.cs
+++ b/Emby.Server.Implementations/EntryPoints/ServerEventNotifier.cs
@@ -25,11 +25,6 @@ namespace Emby.Server.Implementations.EntryPoints
///
private readonly IServerApplicationHost _appHost;
- ///
- /// The task manager.
- ///
- private readonly ITaskManager _taskManager;
-
private readonly ISessionManager _sessionManager;
///
@@ -37,17 +32,14 @@ namespace Emby.Server.Implementations.EntryPoints
///
/// The application host.
/// The installation manager.
- /// The task manager.
/// The session manager.
public ServerEventNotifier(
IServerApplicationHost appHost,
IInstallationManager installationManager,
- ITaskManager taskManager,
ISessionManager sessionManager)
{
_installationManager = installationManager;
_appHost = appHost;
- _taskManager = taskManager;
_sessionManager = sessionManager;
}
@@ -62,8 +54,6 @@ namespace Emby.Server.Implementations.EntryPoints
_installationManager.PackageInstallationCompleted += OnPackageInstallationCompleted;
_installationManager.PackageInstallationFailed += OnPackageInstallationFailed;
- _taskManager.TaskCompleted += OnTaskCompleted;
-
return Task.CompletedTask;
}
@@ -87,11 +77,6 @@ namespace Emby.Server.Implementations.EntryPoints
await SendMessageToAdminSessions("PackageInstallationFailed", e.InstallationInfo).ConfigureAwait(false);
}
- private async void OnTaskCompleted(object sender, TaskCompletionEventArgs e)
- {
- await SendMessageToAdminSessions("ScheduledTaskEnded", e.Result).ConfigureAwait(false);
- }
-
///
/// Installations the manager_ plugin uninstalled.
///
@@ -145,8 +130,6 @@ namespace Emby.Server.Implementations.EntryPoints
_installationManager.PackageInstallationFailed -= OnPackageInstallationFailed;
_appHost.HasPendingRestartChanged -= OnHasPendingRestartChanged;
-
- _taskManager.TaskCompleted -= OnTaskCompleted;
}
}
}
diff --git a/Jellyfin.Server.Implementations/Events/Consumers/System/TaskCompletedNotifier.cs b/Jellyfin.Server.Implementations/Events/Consumers/System/TaskCompletedNotifier.cs
new file mode 100644
index 0000000000..80ed56cd8f
--- /dev/null
+++ b/Jellyfin.Server.Implementations/Events/Consumers/System/TaskCompletedNotifier.cs
@@ -0,0 +1,31 @@
+using System.Threading;
+using System.Threading.Tasks;
+using MediaBrowser.Controller.Events;
+using MediaBrowser.Controller.Session;
+using MediaBrowser.Model.Tasks;
+
+namespace Jellyfin.Server.Implementations.Events.Consumers.System
+{
+ ///
+ /// Notifies admin users when a task is completed.
+ ///
+ public class TaskCompletedNotifier : IEventConsumer
+ {
+ private readonly ISessionManager _sessionManager;
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// The session manager.
+ public TaskCompletedNotifier(ISessionManager sessionManager)
+ {
+ _sessionManager = sessionManager;
+ }
+
+ ///
+ public async Task OnEvent(TaskCompletionEventArgs eventArgs)
+ {
+ await _sessionManager.SendMessageToAdminSessions("ScheduledTaskEnded", eventArgs.Result, CancellationToken.None).ConfigureAwait(false);
+ }
+ }
+}