private IEnumerable <Notification> When(StartJobs message) { while (_pendingJobs.Count > 0) { var pendingJob = _pendingJobs.Dequeue(); _jobs.Add(pendingJob); yield return(pendingJob.StartJob()); } }
public static void Main(string[] args) { // Build the host var host = CreateHostBuilder(args).Build(); // Get the database service from the host using var scope = host.Services.CreateScope(); var services = scope.ServiceProvider; var context = services.GetRequiredService <ApplicationDbContext>(); // Start all jobs StartJobs.StartAllJobs(context).GetAwaiter().GetResult(); // Run host host.Run(); }