[CHANGE] DI fixes

This commit is contained in:
max
2025-09-09 00:58:12 +02:00
parent a5e55e563e
commit d183803390
3 changed files with 20 additions and 3 deletions

View File

@@ -6,15 +6,19 @@ using Manager.YouTube;
namespace Manager.App.Services.System;
public class ClientManager : BackgroundService
public class ClientManager(IServiceScopeFactory scopeFactory, HostedServiceConnector serviceConnector) : BackgroundService
{
private readonly List<YouTubeClient> _clients = [];
private CancellationToken _cancellationToken;
private ILibraryService? _libraryService;
protected override async Task ExecuteAsync(CancellationToken stoppingToken)
{
serviceConnector.RegisterService(this);
_cancellationToken = stoppingToken;
stoppingToken.Register(CancellationRequested);
using var scope = scopeFactory.CreateScope();
_libraryService = scope.ServiceProvider.GetRequiredService<ILibraryService>();
}
private void CancellationRequested()