Пример #1
0
        private void OnTimer(object state)
        {
            var timers = _runtime.PersistenceProvider.GetTimersToExecute();

            foreach (var timer in timers)
            {
                try
                {
                    _runtime.ExecuteTimer(timer.ProcessId, timer.Name);
                }
                finally
                {
                    _runtime.PersistenceProvider.ClearTimer(timer.TimerId);
                }
            }
            RefreshInterval();
        }
Пример #2
0
        private async Task ExecuteTimer(TimerToExecute timer, CancellationToken token)
        {
            if (token.IsCancellationRequested)
            {
                _runtime.PersistenceProvider.ClearTimerIgnore(timer.TimerId);
                return;
            }

            try
            {
                var timerToExecute = timer;
                await _runtime.ExecuteTimer(timerToExecute.ProcessId, timerToExecute.Name);
            }
            // After implementing logger insert log here
            catch (ImpossibleToSetStatusException) {}
            catch (ProcessNotFoundException) {}
            finally
            {
                _runtime.PersistenceProvider.ClearTimer(timer.TimerId);
            }
        }