c# - Why isn't this Quartz schedule repeating? -
the job executes once right away doesn't repeat. doing wrong here?
using system; using system.collections.generic; using system.diagnostics; using system.linq; using system.text; using system.threading; using system.threading.tasks; using quartz; using quartz.impl; namespace quartzconsoleapplication1 { class program { static void main(string[] args) { var schedulerfactory = new stdschedulerfactory(); ischeduler scheduler = schedulerfactory.getscheduler(); scheduler.start(); var jobdetail = jobbuilder .create<samplejob>() .withidentity("myjob", "mygroup") .build(); var trigger = triggerbuilder .create() .withidentity("mytrigger", "mygroup") .withsimpleschedule(c => c.withintervalinseconds(10)) .build(); scheduler.schedulejob(jobdetail, trigger); var stopwatch = new stopwatch(); stopwatch.start(); while (true) { console.writeline("running {0}", stopwatch.elapsed.tostring()); thread.sleep(timespan.fromseconds(10)); } } } public class samplejob : ijob { public void execute(ijobexecutioncontext context) { console.writeline("execute!"); } } }
try adding ".repeatforever()" on schedule.
Comments
Post a Comment