예제 #1
0
        /// <summary>
        /// Advances the enumerator to the next element of the collection.
        /// </summary>
        /// <returns><see langword="true" /> if the enumerator was successfully advanced to the next element; <see langword="false" /> if the enumerator has passed the end of the collection.</returns>
        public bool MoveNext()
        {
            if (MarketTimeChangedInterval != TimeSpan.Zero && !_isTimeLineAdded)
            {
                AddStorage(new InMemoryMarketDataStorage <TimeMessage>(null, null, GetTimeLine));

                _isTimeLineAdded = true;
                _moveNextSyncRoot.WaitSignal();
            }

            if (_messageQueue.Count == 0 && !_isInitialized)
            {
                return(false);
            }

            var isChanged = _isChanged;

            if (isChanged)
            {
                _moveNextSyncRoot.WaitSignal();
            }

            Message message;

            if (!isChanged)
            {
                if (!_messageQueue.TryDequeue(out message))
                {
                    return(false);
                }
            }
            else
            {
                message = _messageQueue.Dequeue().Value;
            }

            var serverTime = message.GetServerTime();

            if (serverTime != null)
            {
                _currentTime = serverTime.Value;
            }

            _currentMessage = (T)message;

            return(true);
        }
예제 #2
0
        /// <summary>
        /// Advances the enumerator to the next element of the collection.
        /// </summary>
        /// <returns><see langword="true" /> if the enumerator was successfully advanced to the next element; <see langword="false" /> if the enumerator has passed the end of the collection.</returns>
        public bool MoveNext()
        {
            if (_messageQueue.Count == 0 && !_isInitialized)
            {
                return(false);
            }

            var isChanged = _isChanged;

            if (isChanged)
            {
                _moveNextSyncRoot.WaitSignal();
            }

            Message message;

            if (!isChanged)
            {
                if (!_messageQueue.TryDequeue(out message))
                {
                    return(false);
                }
            }
            else
            {
                message = _messageQueue.Dequeue().Value;
            }

            var serverTime = message.GetServerTime();

            if (serverTime != null)
            {
                _currentTime = serverTime.Value;
            }

            _currentMessage = (T)message;

            return(true);
        }