/// <summary> /// Starts this job timer. /// </summary> /// <exception cref="ServiceInitializationException"></exception> public override void Start() { if (!string.IsNullOrEmpty(Settings.CrontabExpression)) { CrontabProcessor = _crontabProcessorFactory.Create(Settings.CrontabExpression); CrontabProcessor.CalculateNextOccurrences(); _timer = new Timer(OnCronTimerTick ?? throw new InvalidOperationException("OnCronTimerTick is not assigned"), this, 1000, 60000); } else { _timer = new Timer(OnStartWork ?? throw new InvalidOperationException("OnStartWork is not assigned"), this, 1000, Settings.ProcessingInterval * 1000); } }
/// <summary> /// Starts this job timer. /// </summary> /// <exception cref="ServiceInitializationException"></exception> public override void Start() { if (!string.IsNullOrEmpty(Settings.CrontabExpression)) { CrontabProcessor = _crontabProcessorFactory.Create(Settings.CrontabExpression); CrontabProcessor.CalculateNextOccurrences(); _timer = new Timer(OnCronTimerTick, this, 1000, 60000); } else { _timer = new Timer(OnStartWork, this, 1000, Settings.ProcessingInterval * 1000); } }