Quartz.Net 任务调度之传递参数(2)
2021-05-07 14:27
标签:传递 sync OLE contex get div 参数 class quartz 1.jobDetail 取值 2.Trigger 取值 3.MergedJobDataMap 同样的name,取的是后一个的值 Quartz.Net 任务调度之传递参数(2) 标签:传递 sync OLE contex get div 参数 class quartz 原文地址:https://www.cnblogs.com/mi21/p/12090299.html //添加
//Key:Value
jobDetail.JobDataMap.Add("张翼德", "张翼德");
jobDetail.JobDataMap.Add("year",2019);
public class HelloJob : IJob
{
public async Task Execute(IJobExecutionContext context)
{
await Task.Run(() =>
{
//这里
string name = context.JobDetail.JobDataMap.GetString("张翼德");
int year = context.JobDetail.JobDataMap.GetInt("year");
Console.WriteLine($@"JobDetail{name}" + DateTime.Now + "");
Console.WriteLine("JobDetail 当前年份" + year);
});
}
} //添加
//Key:Value
trigger.JobDataMap.Add("刘玄德", "刘玄德");
trigger.JobDataMap.Add("year", "2020");
public class HelloJob : IJob
{
public async Task Execute(IJobExecutionContext context)
{
await Task.Run(() =>
{
//这里
string name2 = context.Trigger.JobDataMap.GetString("刘玄德");int year2 = context.Trigger.JobDataMap.GetInt("year");
Console.WriteLine($@"Trigger{name2}" + DateTime.Now + "");
Console.WriteLine("Trigger 当前年份" + year2);
});
}
} int year3= context.MergedJobDataMap.GetInt("year");
文章标题:Quartz.Net 任务调度之传递参数(2)
文章链接:http://soscw.com/index.php/essay/83713.html