using PARR.GeneratorTemplates;

namespace PARR.GeneratorTemplatesWorker
{
    public class Worker : BackgroundService
    {
        private readonly ILogger<Worker> _logger;
        private readonly IGeneratorTemplate generatorTemplate;

        public Worker(ILogger<Worker> logger, IGeneratorTemplate generatorTemplate)
        {
            _logger = logger;
            this.generatorTemplate = generatorTemplate;
        }

        protected override async Task ExecuteAsync(CancellationToken stoppingToken)
        {
            await generatorTemplate.StartAsync();
            await Task.Delay(Timeout.Infinite, stoppingToken);
        }

        public override async Task StopAsync(CancellationToken cancellationToken)
        {
            await generatorTemplate.StopAsync();
            await base.StopAsync(cancellationToken);
        }
    }
}