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