using PARR.NextRun; namespace PARR.NextRunWorker { public class RabbitWorker : BackgroundService { private readonly INextRunRabbitService nextRunRabbitService; private readonly ILogger logger; public RabbitWorker(INextRunRabbitService nextRunRabbitService, ILogger logger) { this.nextRunRabbitService = nextRunRabbitService; this.logger = logger; } protected override async Task ExecuteAsync(CancellationToken stoppingToken) { logger.LogInformation("Запуск {workerName}", nameof(RabbitWorker)); await nextRunRabbitService.StartAsync(); } public override Task StopAsync(CancellationToken cancellationToken) { nextRunRabbitService.StopAsync().Wait(); return base.StopAsync(cancellationToken); } } }