20 lines
611 B
C#
20 lines
611 B
C#
using Microsoft.Extensions.DependencyInjection;
|
|
using Quartz;
|
|
using Quartz.Impl;
|
|
|
|
namespace YhCore.Tasks
|
|
{
|
|
/// <summary>
|
|
/// 任务调度注册扩展:Quartz 调度器工厂 + 宿主服务(对应 Java scheduler 自动装配)。
|
|
/// </summary>
|
|
public static class QuartzServiceCollectionExtensions
|
|
{
|
|
public static IServiceCollection AddQuartzHosted(this IServiceCollection services)
|
|
{
|
|
services.AddSingleton<ISchedulerFactory, StdSchedulerFactory>();
|
|
services.AddHostedService<QuartzHostedService>();
|
|
return services;
|
|
}
|
|
}
|
|
}
|