Example #1
0
        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);
        }
Example #2
0
        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;
        }
Example #3
0
        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;
        }
Example #4
0
        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;
        }
Example #5
0
        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);
        }
Example #6
0
        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);
        }
Example #7
0
 public SchedulerTask(Action task, ScheduleInfo schedule, bool needImmediateRun = false)
 {
     _task             = task;
     _schedule         = schedule;
     _needImmediateRun = needImmediateRun;
 }
Example #8
0
 public SchedulerTask(Action task, ScheduleInfo schedule, bool needImmediateRun = false)
 {
     _task = task;
     _schedule = schedule;
     _needImmediateRun = needImmediateRun;
 }