Files
Cleanuparr/code/Executable/DependencyInjection/QuartzDI.cs
Flaminel d2eb9e50e0 fix #13
2025-05-17 20:12:53 +03:00

20 lines
663 B
C#

using Executable.Jobs;
using Quartz;
namespace Executable.DependencyInjection;
public static class QuartzDI
{
public static IServiceCollection AddQuartzServices(this IServiceCollection services, IConfiguration configuration) =>
services
.AddQuartz()
.AddQuartzHostedService(opt =>
{
opt.WaitForJobsToComplete = true;
})
// Register BackgroundJobManager as a hosted service
.AddSingleton<BackgroundJobManager>()
.AddHostedService(provider => provider.GetRequiredService<BackgroundJobManager>());
// Jobs are now managed by BackgroundJobManager
}