Have a list of tasks and their schedules. Say Task1 - Daily 12 PM Task2 - Monday, Wednesday - 9 PM Would like to fire them as per their schedules.
Is it possible to register them with task scheduler or some other scheduler\timers in c# with unique context - the task id. And on call back (say some event), can get the taskid from the context and using the taskid, i can trigger of the actions.
Basically need call back when the scheduled time has been met with the context which has been passed. And my code knows the best, what has to be done during that scheduled time.
Why don't you try using quartz.net. This scheduler support task Id and even context of scheduling. There is also good documentation and lots of examples.
Here is the example of task(aka Job), context of executing is send from scheduler.
public class DumbJob : IJob
{
public DumbJob() {
}
public void Execute(JobExecutionContext context)
{
Console.WriteLine("DumbJob is executing.");
}
}
BTW don't forget to make scheduler static - to avoid being garbage collected. I've already met this problem before.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With