/// <summary> /// Scheduled Tasks Manager /// </summary> public ScheduledTasksCoordinator( ILogger <ScheduledTasksCoordinator> logger, IApplicationLifetime applicationLifetime, IOptions <ScheduledTasksStorage> tasksStorage, IJobsRunnerTimer jobsRunnerTimer, IThisApplication thisApplication, IServiceProvider serviceProvider) { logger.CheckArgumentNull(nameof(logger)); applicationLifetime.CheckArgumentNull(nameof(applicationLifetime)); tasksStorage.CheckArgumentNull(nameof(tasksStorage)); jobsRunnerTimer.CheckArgumentNull(nameof(jobsRunnerTimer)); thisApplication.CheckArgumentNull(nameof(thisApplication)); serviceProvider.CheckArgumentNull(nameof(serviceProvider)); _logger = logger; _tasksStorage = tasksStorage; _jobsRunnerTimer = jobsRunnerTimer; _thisApplication = thisApplication; _serviceProvider = serviceProvider; applicationLifetime.ApplicationStopping.Register(() => { _logger.LogInformation("Application is stopping ... ."); disposeResources().Wait(); }); }
/// <summary> /// Scheduled Tasks Manager /// </summary> public ScheduledTasksCoordinator( ILogger <ScheduledTasksCoordinator> logger, IHostApplicationLifetime applicationLifetime, IOptions <ScheduledTasksStorage> tasksStorage, IJobsRunnerTimer jobsRunnerTimer, IServiceProvider serviceProvider) { _logger = logger ?? throw new ArgumentNullException(nameof(logger)); _tasksStorage = tasksStorage ?? throw new ArgumentNullException(nameof(tasksStorage)); _jobsRunnerTimer = jobsRunnerTimer ?? throw new ArgumentNullException(nameof(jobsRunnerTimer)); _serviceProvider = serviceProvider ?? throw new ArgumentNullException(nameof(serviceProvider)); if (applicationLifetime == null) { throw new ArgumentNullException(nameof(applicationLifetime)); } applicationLifetime.ApplicationStopping.Register(() => { _logger.LogInformation("Application is stopping ... ."); disposeResources().Wait(); }); }