Yes you can reschedule or assign new trigger to the existing scheduler or job, if you had Quartz package verion above ver.3. (If you does have it update throgh nuget package maneger).
For Example: At first I had a scheduler declared within a class FireBaseJob like:
IScheduler scheduler = StdSchedulerFactory.GetDefaultScheduler().Result;
public static void InitializeScheduler()
{
//Getting Defauls Scheduler Job
//Setting trigger time interval, ie. 3min here
int min = 3;
scheduler.Start();
IJobDetail jobDetail = JobBuilder.Create<FirebaseScheduler>().Build();
ITrigger trigger = TriggerBuilder.Create().WithIdentity("FireTrigger1", "FireJob1")
.StartNow().WithSimpleSchedule(s => s.WithIntervalInMinutes(min).RepeatForever()).Build();
scheduler.ScheduleJob(jobDetail, trigger);
}
You can write api,function or within a runing job also you can reschedule a job (for me running job is in the class FirebaseSceduler). I created function to do it.
public ActionResult RescheduleJob()
{
try
{
var triggerBykeyGroup = FirebaseJob.scheduler.GetTrigger(new Quartz.TriggerKey("FireTrigger1", "FireJob1"));
int nextIntervalMinute = 5; // i am setting new trigger minute to 5 mins
TimeSpan newmin = new TimeSpan(0, nextIntervalMinute, 0);
//Updating trigger time interval in minutes
((Quartz.Impl.Triggers.SimpleTriggerImpl)triggerBykeyGroup.Result).RepeatInterval = newmin;
//Getting updated trigger result
var iTrigger = triggerBykeyGroup.Result;
TriggerKey triggerkey = iTrigger.Key;
//Starting paused job
FirebaseJob.scheduler.Start();
//rescheduling Job with updated trigger
FirebaseJob.scheduler.RescheduleJob(triggerkey, iTrigger);
}
catch(Exception ex)
{
}
return Json(new { success = true; });
}
After executing this function Trigger will run in the interval of 5min. Thank You.