/// <summary>
        /// CallBack for timer
        /// </summary>
        /// <param name="arg"> Unused argument because we must not transfert state to callback during the callback.</param>
        private void HandleTick(object arg)
        {
            var nextLastCheck = _watch.ElapsedMilliseconds;
            var newValue      = _updater.UpdateValue(nextLastCheck - _lastCheck);

            _lastCheck = nextLastCheck;
            _current   = _current.UpDateValue(newValue);
            _mdProducer.Post(_current);
        }
 public StockWatcher(IStockUpdater updater, IProducer <StockMarketData> mdProducer, string name, double initValue)
 {
     _timer = new Timer(new TimerCallback(HandleTick), null, 500, 500);
     _watch = new Stopwatch();
     _watch.Start();
     _updater    = updater;
     _mdProducer = mdProducer;
     _current    = new StockMarketData(name, initValue, initValue, initValue);
 }