Friday, January 6, 2012

Quartz scheduler job that re-triggers itself on completion

  1. public class RetriggerJob : IInterruptableJob
  2. {
  3. private bool _interrupted;
  4. public void Execute(IJobExecutionContext context)
  5. {
  6. Thread.Sleep(1000);
  7. if (_interrupted)
  8. {
  9. return;
  10. }
  11. context.Scheduler.TriggerJob(context.JobDetail.Key);
  12. if (_interrupted)
  13. {
  14. context.Scheduler.Interrupt(context.JobDetail.Key);
  15. }
  16. }
  17. public void Interrupt()
  18. {
  19. _interrupted = true;
  20. }
  21. }
Quartz.NET

No comments: