To send push notification daily with the interval of 24 hour, i've use quartz library. But the issue is when my pc is turned off or my network is disconnected, this peace of code is also triggered but my push notification is not send. My question is how can i manage trigger when my pc is turned off or network disconnected? I want to send push notification after my pc is turned on or connected to the internet.
ITrigger trigger = TriggerBuilder.Create()
.WithDailyTimeIntervalSchedule
(s =>
s.WithIntervalInHours(24)
.OnEveryDay()
.StartingDailyAt(TimeOfDay.HourAndMinuteOfDay(11, 00))
)
.Build();
scheduler.ScheduleJob(job, trigger);
You need a combination of Misfire Instructions, a JobExecutionException and the DisallowConcurrentExecutionAttribute
Set the
DisallowConcurrentExecutionAttribute
on your Job, this will prevent you from executing multiple instances of the same jobs at the same time.Set the
Misfire Instruction
to your Trigger, this will tell your trigger to fire immediately in case it missed an execution.Catch any exception during the execution of your job e.g. when the internet is not reachable and throw a
JobExecutionException
telling Quartz that the trigger should be fired again.Next time, read the documentation first ;)