public static IHostBuilder CreateHostBuilder(string[] args) { return(Host.CreateDefaultBuilder(args) .UseWindowsService() .ConfigureServices((hostContext, services) => { IConfiguration configuration = hostContext.Configuration; WorkerConfig options = configuration.GetSection("JOB").Get <WorkerConfig>(); services.AddSingleton(options); services.AddHostedService <Worker>(); }) .UseSerilog()); }
public Worker(ILogger <Worker> logger, WorkerConfig options) { _logger = logger; this.options = options; }