Пример #1
0
        private System.Timers.Timer CreateTimer(PollerTimeoutCalculator timeoutCalc)
        {
            var timeout = timeoutCalc.CalculateNext();
            var result  = new System.Timers.Timer(timeout)
            {
                AutoReset = false
            };

            result.Elapsed += OnTimerElapsed;
            return(result);
        }
Пример #2
0
        public Runner(IContractsRegistry contractsRegistry, ILogger logger, IPollerStateRepository stateRepository, SubscriptionPoller poller, IUpConverterFactory upConverterFactory)
        {
            if (poller == null)
            {
                throw new ArgumentNullException(nameof(poller));
            }
            Poller = poller;

            _pollerContext = new PollerContext(contractsRegistry, logger, stateRepository, upConverterFactory);
            _startedAt     = new InterlockedDateTime(DateTime.MaxValue);
            _timeoutCalc   = new PollerTimeoutCalculator(Poller.GetFetchTimeout());
            _runnerTimer   = CreateTimer(_timeoutCalc);
        }