Esempio n. 1
0
 public bool ContainsKey(K key)
 {
     using (AutoLock.LockToRead(_lock, _timeout))
     {
         return(_dictionary.ContainsKey(key));
     }
 }
Esempio n. 2
0
 public bool ContainsValue(V value)
 {
     using (AutoLock.LockToRead(_lock, _timeout))
     {
         return(_dictionary.ContainsValue(value));
     }
 }
Esempio n. 3
0
        /// <summary>
        /// Retrieves the next item in the queue without removing the item.
        /// </summary>
        /// <param name="trimWhenEmpty">true to trim the queue size when empty</param>
        /// <returns>T object or default T object when empty</returns>
        public T GetNextItem(bool trimWhenEmpty)
        {
            using (AutoLock.LockToRead(_lock, _timeout))
            {
                if (0 != _queue.Count)
                {
                    return(_queue.Peek( ));
                }
                else
                {
                    if (trimWhenEmpty)
                    {
                        // Release the queue memory (by default, once the queue grows,
                        // it won't release any allocated memory even if it's empty)
                        _queue.TrimExcess( );
                    }
                }
            }

            return(default(T));
        }
Esempio n. 4
0
 public V this [K key]
 {
     get { using (AutoLock.LockToRead(_lock, _timeout)) { return(_dictionary [key]); } }
     set { using (AutoLock.LockToWrite(_lock, _timeout)) { _dictionary [key] = value; } }
 }