本文整理汇总了C#中Quartz.Impl.StdSchedulerFactory.TriggerJob方法的典型用法代码示例。如果您正苦于以下问题:C# StdSchedulerFactory.TriggerJob方法的具体用法?C# StdSchedulerFactory.TriggerJob怎么用?C# StdSchedulerFactory.TriggerJob使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Quartz.Impl.StdSchedulerFactory
的用法示例。
在下文中一共展示了StdSchedulerFactory.TriggerJob方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Main
static void Main(string[] args)
{
//ScheduledJob.Run();
// TODO: Initialiaze Scheduler
var scheduler = new StdSchedulerFactory().GetScheduler();
scheduler.Start();
var jobDetail = JobBuilder.Create<ExampleJob>()
.WithIdentity(new JobKey("ExampleJob"))
.Build();
jobDetail.JobDataMap.Put("DataKey", "Passed value");
jobDetail.JobDataMap.Put("FilePath", ConfigurationManager.AppSettings["FilePath"] as string);
// Let's create a trigger that fires immediately
ICronTrigger trigger = TriggerBuilder.Create()
.WithIdentity("WriteHelloToLog", "IT")
.WithCronSchedule("0 0/1 * 1/1 * ? *") //-> visit http://www.cronmaker.com/ Queues the job every minute
.StartAt(DateTime.UtcNow)
.WithPriority(1)
.Build() as ICronTrigger;
ITrigger dailyTrigger = TriggerBuilder.Create()
.WithDailyTimeIntervalSchedule(schedBuilder => schedBuilder
.WithIntervalInMinutes(30)
.OnDaysOfTheWeek(new[] {
DayOfWeek.Monday,
DayOfWeek.Tuesday,
DayOfWeek.Wednesday,
DayOfWeek.Thursday,
DayOfWeek.Friday })
.StartingDailyAt(TimeOfDay.HourAndMinuteOfDay(9, 30))
.EndingDailyAt(TimeOfDay.HourAndMinuteOfDay(19, 30)))
.Build();
scheduler.ScheduleJob(jobDetail, trigger);
scheduler.TriggerJob(new JobKey("ExampleJob"));
}
示例2: OnStart
protected override void OnStart(string[] args)
{
//ScheduledJob.Run();
// TODO Initialiaze Scheduler
var scheduler = new StdSchedulerFactory().GetScheduler();
scheduler.Start();
var jobDetail = JobBuilder.Create<HelloWorldJob>()
.WithIdentity(new JobKey("HelloWorldJob"))
.Build();
jobDetail.JobDataMap.Put("DataKey", "Passed value");
jobDetail.JobDataMap.Put("FilePath", System.Configuration.ConfigurationManager.AppSettings["FilePath"] as string);
// Let's create a trigger that fires immediately
var trigger = (ICronTrigger)TriggerBuilder.Create()
.WithIdentity("WriteHelloToLog", "IT")
.WithCronSchedule("0 0/1 * 1/1 * ? *") // visit http://www.cronmaker.com/ Queues the job every minute
.StartAt(DateTime.UtcNow)
.WithPriority(1)
.Build();
scheduler.ScheduleJob(jobDetail, trigger);
scheduler.TriggerJob(new JobKey("HelloWorldJob"));
}