0

I have a job scheduled in Application_start event using quartz.net, the trigger is fired every 1 min given by the variable repeatDurationTestData = "0 0/1 * * * ?"; The triggering starts when I first open the site, But stops after some random time when I close the browser and starts again when I open the site. Following is the code

 IMyJob testData = new SynchronizeTestData();
 IJobDetail jobTestData = new JobDetailImpl("Job", "Group", testData.GetType());
 ICronTrigger triggerTestData = new CronTriggerImpl("Trigger", "Group", repeatDurationTestData);
 _scheduler.ScheduleJob(jobTestData, triggerTestData);
 DateTimeOffset? nextFireTime = triggerTestData.GetNextFireTimeUtc();

What Am i doing wrong here, Is this because of some misfire. Please suggest.

Thanks

Karthik Ganesan
  • 4,142
  • 2
  • 26
  • 42

1 Answers1

2

At First I would use a simple trigger in this case as it takes a repeat interval and seems to fit better than the cron trigger would (from lesson 5 quartz.net website) :

SimpleTrigger trigger2 = new SimpleTrigger("myTrigger",
                            null,
                            DateTime.UtcNow,
                            null,
                            SimpleTrigger.RepeatIndefinitely,
                            TimeSpan.FromSeconds(60)); 

I would also recommend you don't put the quartz scheduler within the website. the main purpose of a job system is to work independently of anyother system so it generally fits naturally into a windows service. By putting it as part of the website you arn't guaranteed its going to keep going. If you loose the app pool or it restarts, you wont get a reliable result.

There is an example with the quartz.net download.

hope that helps.

mjyazdani
  • 2,110
  • 6
  • 33
  • 64
Mocksy
  • 360
  • 2
  • 7