public SchedulerTask RecurringRun(TimeSpan firstRunDelay, TimeSpan interval, Action task) { DateTime firstRun = DateTime.Now.Add(firstRunDelay); var schedule = new ScheduleInfo(firstRun, interval); var schedulerTask = new SchedulerTask(task, schedule); _tasks.Add(schedulerTask); return(schedulerTask); }
public SchedulerTask RecurringRun(TimeSpan firstRunDelay, TimeSpan interval, Action task) { DateTime firstRun = DateTime.Now.Add(firstRunDelay); var schedule = new ScheduleInfo(firstRun, interval); var schedulerTask = new SchedulerTask(task, schedule); _tasks.Add(schedulerTask); return schedulerTask; }
public SchedulerTask SingleRun(DateTime executionTime, Action task) { if (executionTime < DateTime.Now) throw new ArgumentException("Execution time value can't be in the past", "executionTime"); var schedule = new ScheduleInfo(executionTime, TimeSpan.Zero); var schedulerTask = new SchedulerTask(task, schedule); _tasks.Add(schedulerTask); return schedulerTask; }
public SchedulerTask DailyRun(TimeSpan timeOfDay, Action task, bool immediateFirstRun = false) { var firstRun = DateTime.Today.Add(timeOfDay); if (firstRun < DateTime.Now) firstRun = firstRun.AddDays(1); var schedule = new ScheduleInfo(firstRun, TimeSpan.FromDays(1)); var schedulerTask = new SchedulerTask(task, schedule, immediateFirstRun); _tasks.Add(schedulerTask); return schedulerTask; }
public SchedulerTask SingleRun(DateTime executionTime, Action task) { if (executionTime < DateTime.Now) { throw new ArgumentException("Execution time value can't be in the past", "executionTime"); } var schedule = new ScheduleInfo(executionTime, TimeSpan.Zero); var schedulerTask = new SchedulerTask(task, schedule); _tasks.Add(schedulerTask); return(schedulerTask); }
public SchedulerTask DailyRun(TimeSpan timeOfDay, Action task, bool immediateFirstRun = false) { var firstRun = DateTime.Today.Add(timeOfDay); if (firstRun < DateTime.Now) { firstRun = firstRun.AddDays(1); } var schedule = new ScheduleInfo(firstRun, TimeSpan.FromDays(1)); var schedulerTask = new SchedulerTask(task, schedule, immediateFirstRun); _tasks.Add(schedulerTask); return(schedulerTask); }
public SchedulerTask(Action task, ScheduleInfo schedule, bool needImmediateRun = false) { _task = task; _schedule = schedule; _needImmediateRun = needImmediateRun; }