Пример #1
0
 public void Register(JobDefinition def)
 {
     if (IsJobRegisterd(def.JobKey))
     {
         throw new InvalidOperationException("Job with key " + def.JobKey + " already registered.\r\n"
                                             + "You can use IsJobRegisterd to check if job is already registered");
     }
     _items.TryAdd(def.JobKey, new JobItemFactory(_context).Create(def));
 }
 public void Register(JobDefinition def)
 {
     if (IsJobRegisterd(def.JobKey))
     {
         throw new InvalidOperationException("Job with key " + def.JobKey + " already registered.\r\n"
             + "You can use IsJobRegisterd to check if job is already registered");
     }
     _items.TryAdd(def.JobKey, new JobItemFactory(_context).Create(def));
 }
Пример #3
0
        public JobItem(ISchedulerContext context, JobDefinition definition, WorkState presavedState = null)
        {
            _context = context;
            _definition = definition;
            _created = _context.GetCurrentTime();

            if (presavedState != null)
            {
                _lastCompleteTime = presavedState.LastCompleteTime;
            }

            UpdateState();
        }
Пример #4
0
        public JobItem(ISchedulerContext context, JobDefinition definition, WorkState presavedState = null)
        {
            _context    = context;
            _definition = definition;
            _created    = _context.GetCurrentTime();

            if (presavedState != null)
            {
                _lastCompleteTime = presavedState.LastCompleteTime;
            }

            UpdateState();
        }
 public void Schedule(JobDefinition definition)
 {
     if (!_work.IsJobRegisterd(definition.JobKey))
     {
         _work.Register(definition);
     }
 }
 public void Schedule(string workKey, Func<Task> factory, TimeSpan interval, string description = null)
 {
     var definition = new JobDefinition(workKey, factory, Schedules.Interval(interval), description);
     Schedule(definition);
 }
 public void Schedule(string workKey, Action work, TimeSpan interval, string description = null)
 {
     Func<Task> factory = () => Task.Factory.StartNew(work);
     var definition = new JobDefinition(workKey, factory, Schedules.Interval(interval), description);
     Schedule(definition);
 }