18

I have some Quartz.Net jobs which are running on a Schedule

scheduler.ScheduleJob(
new JobDetailImpl("MarkAsSolutionReminderJob", typeof(MarkAsSolutionReminderJob)),
new CalendarIntervalTriggerImpl("MarkAsSolutionReminderJobTrigger", IntervalUnit.Hour, 6));

Is it possible for me to manually trigger this Job to run when I want it to?

So it continues to run as normal, but in a specific piece of code I might want to just run it out of schedule once or twice. But it doesn't affect the scheduled job?

walen
  • 7,103
  • 2
  • 37
  • 58
YodasMyDad
  • 9,248
  • 24
  • 76
  • 121

1 Answers1

25

Is it possible for me to manually trigger this Job to run when I want it to?

Yes, you can trigger this job as and when you need.

Use void TriggerJob(JobKey jobKey) method for this as below:

scheduler.TriggerJob(new Jobkey("MarkAsSolutionReminderJob"));

If you want to pass some data to the job while executing it on demand, you can also do that by just using another overload void TriggerJob(JobKey jobKey, JobDataMap data); of the same method as below:

Dictionary<string, string> data = new Dictionary<string, string>();
//populate dictionary as per your needs
JobDataMap jobData = new JobDataMap(data);
scheduler.TriggerJob(new Jobkey("MarkAsSolutionReminderJob"),jobData);
Bhushan Firake
  • 9,338
  • 5
  • 44
  • 79