How can I create a one time cron schedule that would execute only once in C#?


have used cron schedule in c# create application should trigger job once. code piece throwing exception, unhandled exception of type 'quartz.schedulerexception' occurred in quartz.dll

below code:

class program  {      static void main(string[] args)      {          test();      }        public static void test()      {          ischedulerfactory schedulerfactory = new stdschedulerfactory();          ischeduler scheduler = schedulerfactory.getscheduler();            ijobdetail jobdetail = jobbuilder.create<satellitepaymentgenerationjob>()              .withidentity("testjob")              .build();          console.writeline(datebuilder.dateof(16, 30, 00, 24, 2, 2015));          //itrigger trigger = triggerbuilder.create()          //    .forjob(jobdetail)          //    .withcronschedule("0 0 12 20 4 ? *")          //    .withidentity("testtrigger")          //    .startnow()          //    .build();          itrigger trigger = triggerbuilder.create()                               .withdescription("once")                               .withsimpleschedule(x => x.repeatforever().withrepeatcount(1))                               .startat(datebuilder.dateof(12, 43, 00, 26, 2, 2015))                               .build();            scheduler.schedulejob(jobdetail, trigger);          scheduler.start();      }  }    internal class satellitepaymentgenerationjob : ijob  {      public void execute(ijobexecutioncontext context)      {          console.writeline("test");      }  }
i believe way have done scheduling execute once causing issue. please advice.



mayooran99

hi mayooran99,

from additional information: repeat interval cannot zero. screenshot as below.

you should specify repeat interval in seconds. 

please try following code

itrigger triggers = triggerbuilder.create()                                .withdescription("once")                                .withsimpleschedule(x => x                                .withintervalinseconds(20)                                .repeatforever())                                .startat(datebuilder.dateof(12, 43, 00, 26, 2, 2015))                                .build();

have nice day!

kristin


we trying better understand customer views on social support experience, participation in interview project appreciated if have time. helping make community forums great place.
click here participate survey.



Visual Studio Languages  ,  .NET Framework  >  Visual C#



Comments

Popular posts from this blog

Azure DocumentDB Owner resource does not exist

job syspolicy_purge_history job fail in sqlserver 2008

Trying to register with public marketplace error with 'Get-AzureStackStampInformation'