TheWebGuy
TheWebGuy

Reputation: 12545

Quartz.net firing previously scheduled jobs

I just started using Quartz.net. I wrote a little routine to schedule multiple jobs. I am really not sure if I coded this properly. Hopefully there are some Quartz.NET experts that can help. I have three questions:

  1. Does my trigger setup look correct? I would like to run a job everyday at 9AM and 3PM (I know you can't see the market.LocalOpenTime property but its always today's date at 9AM and the other object has 3PM.

  2. I noticed when I run the program, it will always run the 9AM job (scheduled in the past). Anyway I can turn off this feature? I ran the program at 1PM. I assume if I run it at 4PM it will run these two past scheduled jobs.

  3. How can I go about only running these jobs on weekdays?

    foreach (IJob job in GetJobsToSchedule())
    {
        i++;
        var market = (IMarket)job;
    
        IJobDetail jobDetail = new JobDetailImpl(market.JobName, null, market.GetType());           
        ITrigger trigger = new SimpleTriggerImpl(market.JobName, i.ToString(), market.LocalOpenTime, null, 1000, new TimeSpan(1, 0, 0, 0));
    
        sched.ScheduleJob(jobDetail, trigger);
    }
    

Upvotes: 1

Views: 846

Answers (1)

Daniel Gabriel
Daniel Gabriel

Reputation: 3985

1) You might want to consider using a CronTriggerImpl with a schedule of 0 0 9,15 * * ?. This will allow you to set your whole schedule with 1 trigger. Here is a good tutorial on cron triggers (even though it's for the previous Quartz version): http://quartznet.sourceforge.net/tutorial/lesson_6.html

2) Set the myCronTrigger.MisfireInstruction property to DoNothing. The documentation says this value should be defined in the CronTriggerImpl class but I didn't see it. You may have better luck using IntelliSense in Visual Studio.

3) Check out the Cron tutorial link in (1) above. You could use something like this: 0 0 9,15 * * MON-FRI

Upvotes: 3

Related Questions