Пример #1
0
        public override Task ExecuteAsync(CancellationToken stoppingToken)
        {
            _logger.LogInformation($"{nameof(JobStarter)} started at {DateTimeOffset.Now}.");

            if (_scheduler.Jobs.Any())
            {
                _scheduler.RemoveJobAsync(_scheduler.Jobs.Select(job => job.Name).First());
            }
            else
            {
                _scheduler.AddJob(new ChildJob(_childLogger)
                {
                    ChildName = $"Child-{Interlocked.Increment(ref _childCounter)}"
                });
            }

            return(Task.CompletedTask);
        }