Example #1
0
        /// <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();
            });
        }