public async Task TestConcurrencyLimit() { JobHandler.jobFactory = new MockJobFactory(); var jobSchedulerService = new JobSchedulerService(); var jobs = new List <IJobQueue>(); for (int i = 0; i < 3; i++) { var job = new WebScrapeJob(); await jobSchedulerService.ScheduleJobAsync(job); jobs.Add(job); Console.WriteLine(job.RequestId); } Thread.Sleep(TimeSpan.FromSeconds(2)); foreach (IJobQueue job in jobs) { var jobStatus = await jobSchedulerService.GetJobAsync(job.RequestId); Console.WriteLine("{0} {1}", job.RequestId, jobStatus.Status); if (jobs.IndexOf(job) == jobs.Count - 1) { Assert.AreEqual(JobStatus.QUEUED, jobStatus.Status); } else { Assert.AreEqual(JobStatus.RUNNING, jobStatus.Status); } } }
public async Task TestStart() { var context = new FakeJobContext(); var data = new TaskCompletionSource <bool>(); var serviceProvider = new ServiceCollection().BuildServiceProvider(); var jobScheduler = new JobSchedulerService <TaskCompletionSource <bool>, FakeJobContext>(serviceProvider); await jobScheduler.StartAsync(default);
public AdminController(IOptions <SiteOptions> options, DatabaseContext database, JobSchedulerService <MailJob, MailJobContext> scheduler, AuthenticationService authentication) { this.options = options; this.database = database; this.scheduler = scheduler; this.authentication = authentication; }
public BlogPostController(IOptions <SiteOptions> options, DatabaseContext database, JobSchedulerService <MailJob, MailJobContext> scheduler, AuthenticationService authentication, MarkdownService markdown) { this.options = options; this.database = database; this.scheduler = scheduler; this.authentication = authentication; this.markdown = markdown; }
public async Task LoadEventsFeed() { var list = await _bibleVersesDataService.GetBibleVerses(); Task.Run(() => { JobSchedulerService.ScheduleJobs(list); }); }