Exemplo n.º 1
0
        /// <summary>
        /// Does the work of adding an item to the list. Must be called from within a lock.
        /// </summary>
        /// <param name="item"></param>
        /// <param name="raiseCountChanged"></param>
        private void DoAdd(T item, bool raiseCountChanged)
        {
            var collectionItem = new ExpiringCollection <T> .CollectionItem <T>(item, _Clock.UtcNow);

            _List.Add(collectionItem);

            if (_List.Count == 1)
            {
                HookHeartbeat();
            }

            if (raiseCountChanged)
            {
                OnCountChanged(_List.Count);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Does the work of adding a new item to the dictionary. The key must not already exist.
        /// Must be called from within a lock.
        /// </summary>
        /// <param name="key"></param>
        /// <param name="value"></param>
        /// <param name="raiseCountChanged"></param>
        private void DoAdd(TKey key, TValue value, bool raiseCountChanged)
        {
            var collectionItem = new ExpiringCollection <TValue> .CollectionItem <TValue>(value, _Clock.UtcNow);

            _Dictionary.Add(key, collectionItem);

            if (_Dictionary.Count == 1)
            {
                HookHeartbeat();
            }

            if (raiseCountChanged)
            {
                OnCountChanged(_Dictionary.Count);
            }
        }