From e37de354456655254e6d6aba0681b52a045bcf3b Mon Sep 17 00:00:00 2001 From: rlauuzo <46294892+rlauuzo@users.noreply.github.com> Date: Thu, 11 Apr 2024 16:58:37 +0200 Subject: [PATCH] Make Entrypoint run at start (#109) * Update Entrypoint.cs * Update PluginServiceRegistrator.cs --- ConfusedPolarBear.Plugin.IntroSkipper/Entrypoint.cs | 11 +++++++---- .../PluginServiceRegistrator.cs | 1 + 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/ConfusedPolarBear.Plugin.IntroSkipper/Entrypoint.cs b/ConfusedPolarBear.Plugin.IntroSkipper/Entrypoint.cs index 66a4d48..1195e54 100644 --- a/ConfusedPolarBear.Plugin.IntroSkipper/Entrypoint.cs +++ b/ConfusedPolarBear.Plugin.IntroSkipper/Entrypoint.cs @@ -84,6 +84,13 @@ public class Entrypoint : IHostedService, IDisposable /// public Task StopAsync(CancellationToken cancellationToken) { + _libraryManager.ItemAdded -= OnItemAdded; + _libraryManager.ItemUpdated -= OnItemModified; + _taskManager.TaskCompleted -= OnLibraryRefresh; + + // Stop the timer + _queueTimer.Change(Timeout.Infinite, 0); + return Task.CompletedTask; } @@ -283,10 +290,6 @@ public class Entrypoint : IHostedService, IDisposable { if (!dispose) { - _libraryManager.ItemAdded -= OnItemAdded; - _libraryManager.ItemUpdated -= OnItemModified; - _taskManager.TaskCompleted -= OnLibraryRefresh; - _queueTimer.Dispose(); return; diff --git a/ConfusedPolarBear.Plugin.IntroSkipper/PluginServiceRegistrator.cs b/ConfusedPolarBear.Plugin.IntroSkipper/PluginServiceRegistrator.cs index 6bc818c..2f3459a 100644 --- a/ConfusedPolarBear.Plugin.IntroSkipper/PluginServiceRegistrator.cs +++ b/ConfusedPolarBear.Plugin.IntroSkipper/PluginServiceRegistrator.cs @@ -13,6 +13,7 @@ namespace ConfusedPolarBear.Plugin.IntroSkipper public void RegisterServices(IServiceCollection serviceCollection, IServerApplicationHost applicationHost) { serviceCollection.AddHostedService(); + serviceCollection.AddHostedService(); } } }