Until I used Quartz.NET, I used Quartz in Java projects, and I think they are similar. I implemented a solution similar to what you are describing. In the executeInteral method, you have access to the execution context of the job. This is mainly due to the creation of a new trigger and the subsequent re-planning of the task (rescheduleJob). Therefore, when a condition arises, you will do something like:
protected void ExecuteInternal( IJobExecutionContext context ) { // ... some code if (the_condition) { // figure out startTime // figure out endTime // figure out repeat time // figoure out repeatInterval Trigger trigger = new SimpleTrigger("OurNewTrigger","GROUP_NAME", context.getJobDetail().getName(),context.getJobDetail().getGroup(), startTime, endTime,repeatTime,repeatInterval); context.getScheduler().rescheduleJob("OurNewTrigger","GROUP_NAME",trigger); } // ... some more code }
Along these lines. Hope this helps.
source share