public WindowsFormsLifetime(
     IOptions <WindowsFormsLifetimeOptions> options,
     IHostEnvironment environment,
     IHostApplicationLifetime hostApplicationLifetime,
     ILoggerFactory loggerFactory)
 {
     _options             = options?.Value ?? throw new ArgumentNullException(nameof(options));
     _environment         = environment ?? throw new ArgumentNullException(nameof(environment));
     _applicationLifetime = hostApplicationLifetime ?? throw new ArgumentNullException(nameof(hostApplicationLifetime));
     _logger = loggerFactory?.CreateLogger("Microsoft.Hosting.Lifetime") ?? throw new ArgumentNullException(nameof(loggerFactory));
 }
 public WindowsFormsHostedService(
     IOptions <WindowsFormsLifetimeOptions> options,
     IHostApplicationLifetime hostApplicationLifetime,
     IServiceProvider serviceProvider,
     WindowsFormsSynchronizationContextProvider syncContextManager,
     Action <IServiceProvider> preApplicationRunAction)
 {
     _options = options.Value;
     _hostApplicationLifetime = hostApplicationLifetime;
     _serviceProvider         = serviceProvider;
     _syncContextManager      = syncContextManager;
     PreApplicationRunAction  = preApplicationRunAction;
 }