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); }
public Task <bool> AddAsync(Job job, CancellationToken cancellationToken) { return(Task.FromResult(_manager.AddJob <OnDemandJob>(demandJob => demandJob.Initalize(job.Name, job.Expression)))); }