29 lines
910 B
C#
29 lines
910 B
C#
using PARR.NextRun;
|
|
|
|
namespace PARR.NextRunWorker
|
|
{
|
|
public class RabbitWorker : BackgroundService
|
|
{
|
|
private readonly INextRunRabbitService nextRunRabbitService;
|
|
private readonly ILogger<RabbitWorker> logger;
|
|
|
|
public RabbitWorker(INextRunRabbitService nextRunRabbitService, ILogger<RabbitWorker> 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);
|
|
}
|
|
}
|
|
}
|