Exemplo n.º 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);
        }
Exemplo n.º 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;
        }
Exemplo n.º 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;
        }
Exemplo n.º 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;
        }
Exemplo n.º 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);
        }
Exemplo n.º 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);
        }
Exemplo n.º 7
0
 public SchedulerTask(Action task, ScheduleInfo schedule, bool needImmediateRun = false)
 {
     _task             = task;
     _schedule         = schedule;
     _needImmediateRun = needImmediateRun;
 }
Exemplo n.º 8
0
 public SchedulerTask(Action task, ScheduleInfo schedule, bool needImmediateRun = false)
 {
     _task = task;
     _schedule = schedule;
     _needImmediateRun = needImmediateRun;
 }