我用这种方式使用Quartz.NET:
ISchedulerFactory schedulerFactory = new StdSchedulerFactory();
IScheduler scheduler = schedulerFactory.GetScheduler();
scheduler.Start();
IJobDetail clearCacheJob = JobBuilder.Create<ClearCacheJob>()
.WithIdentity("ClearCacheJob", "CacheGroup")
.Build();
scheduler.ScheduleJob(clearCacheJob, buildTrigger(cacheCronExpr));
ClearCacheJob
是一个实现IJob
它有效,但现在我想在ClearCacheJob
类中添加一个属性。类似的东西:
public class ClearCacheJob : IJob
{
public ISomeService {get; set;}
public void Execute(IJobExecutionContext context)
{
//do stuff
}
}
如何设置SomeService
?
答案 0 :(得分:3)
就DI容器而言,Castle也受到支持。执行search on NuGet for Quartz.Net并滚动列表。你会看到castle,structuremap,ninject,autofac等。