Make Entrypoint run at start (#109)

* Update Entrypoint.cs

* Update PluginServiceRegistrator.cs
This commit is contained in:
rlauuzo 2024-04-11 16:58:37 +02:00 committed by GitHub
parent 36afd6ce53
commit e37de35445
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 8 additions and 4 deletions

View File

@ -84,6 +84,13 @@ public class Entrypoint : IHostedService, IDisposable
/// <inheritdoc /> /// <inheritdoc />
public Task StopAsync(CancellationToken cancellationToken) 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; return Task.CompletedTask;
} }
@ -283,10 +290,6 @@ public class Entrypoint : IHostedService, IDisposable
{ {
if (!dispose) if (!dispose)
{ {
_libraryManager.ItemAdded -= OnItemAdded;
_libraryManager.ItemUpdated -= OnItemModified;
_taskManager.TaskCompleted -= OnLibraryRefresh;
_queueTimer.Dispose(); _queueTimer.Dispose();
return; return;

View File

@ -13,6 +13,7 @@ namespace ConfusedPolarBear.Plugin.IntroSkipper
public void RegisterServices(IServiceCollection serviceCollection, IServerApplicationHost applicationHost) public void RegisterServices(IServiceCollection serviceCollection, IServerApplicationHost applicationHost)
{ {
serviceCollection.AddHostedService<AutoSkip>(); serviceCollection.AddHostedService<AutoSkip>();
serviceCollection.AddHostedService<Entrypoint>();
} }
} }
} }