コード例 #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));
 }
コード例 #2
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));
 }
コード例 #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();
        }
コード例 #5
0
 public void Schedule(JobDefinition definition)
 {
     if (!_work.IsJobRegisterd(definition.JobKey))
     {
         _work.Register(definition);
     }
 }
コード例 #6
0
 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);
 }
コード例 #7
0
 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);
 }