Exemple #1
0
        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());
        }
Exemple #2
0
 public Worker(ILogger <Worker> logger, WorkerConfig options)
 {
     _logger      = logger;
     this.options = options;
 }