SchedulerTask RunForever() { IsRecurring = true; NextTime = DateTime.UtcNow.Add(Delay); Scheduler.AddTask(this); return(this); }
/// <summary> Runs the task once, as quickly as possible. /// Callback is invoked from the Scheduler thread. </summary> public SchedulerTask RunOnce() { NextTime = DateTime.UtcNow.Add(Delay); IsRecurring = false; Scheduler.AddTask(this); return(this); }
/// <summary> Runs the task once at a given date. /// If the given date is in the past, the task is ran immediately. </summary> public SchedulerTask RunOnce(DateTime time) { Delay = time.Subtract(DateTime.UtcNow); NextTime = time; IsRecurring = false; Scheduler.AddTask(this); return(this); }
/// <summary> Executes the task once at a given time, and suspends (but does not stop). /// A SchedulerTask object can be reused many times if ran manually. </summary> public SchedulerTask RunManual(DateTime time) { Delay = time.Subtract(DateTime.UtcNow); IsRecurring = true; NextTime = time; MaxRepeats = -1; Interval = CloseEnoughToForever; Scheduler.AddTask(this); return(this); }
/// <summary> Executes the task once after a delay, and suspends (but does not stop). /// A SchedulerTask object can be reused many times if ran manually. </summary> public SchedulerTask RunManual(TimeSpan delay) { Delay = delay; IsRecurring = true; NextTime = DateTime.UtcNow.Add(Delay); MaxRepeats = -1; Interval = CloseEnoughToForever; Scheduler.AddTask(this); return(this); }