コード例 #1
0
        public Task StartAsync(CancellationToken cancellationToken)
        {
            StartOrRestartTimer();

            _optionsChangeListener = _optionsMonitor.OnChange(options =>
            {
                _options = options;
                StartOrRestartTimer();
            });

            return(Task.CompletedTask);
        }
コード例 #2
0
        public JobScheduler(
            IOptionsMonitor <ScheduledJobOptions <TScheduledJob> > optionsMonitor,
            IServiceProvider serviceProvider,
            ILogger <JobScheduler <TScheduledJob> > logger
            )
        {
            _optionsMonitor  = optionsMonitor;
            _serviceProvider = serviceProvider;
            _logger          = logger;

            _options = optionsMonitor.CurrentValue;

            _semaphoreSlim = new SemaphoreSlim(1, 1);
            _timer         = new Timer(TimerCallback, null, Timeout.Infinite, Timeout.Infinite);
        }