using PARR.TemplateUpdater;

namespace PARR.TemplateUpdaterWorker
{
    public class Worker : BackgroundService
    {
        private readonly ILogger<Worker> _logger;
        private readonly ITemplateUpdater templateUpdater;

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

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

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

    }
}
