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