Exemplo n.º 1
0
        public TValue this[TKey key]
        {
            get
            {
                LockQ.EnterReadLock();
                try
                {
                    return(dict[key]);
                }
                finally
                {
                    LockQ.ExitReadLock();
                }
            }

            set
            {
                LockQ.EnterWriteLock();
                try
                {
                    dict[key] = value;
                }
                finally
                {
                    LockQ.ExitWriteLock();
                }
            }
        }
 public bool TryGetValue(TKey key, out TValue value)
 {
     LockQ.EnterReadLock();
     try
     {
         return(dict.TryGetValue(key, out value));
     }
     finally
     {
         LockQ.ExitReadLock();
     }
 }
 public bool ContainsKey(TKey key)
 {
     LockQ.EnterReadLock();
     try
     {
         return(dict.ContainsKey(key));
     }
     finally
     {
         LockQ.ExitReadLock();
     }
 }
Exemplo n.º 4
0
 public virtual void CopyTo(KeyValuePair <TKey, TValue>[] array, int arrayIndex)
 {
     LockQ.EnterReadLock();
     try
     {
         dict.CopyTo(array, arrayIndex);
     }
     finally
     {
         LockQ.ExitReadLock();
     }
 }
Exemplo n.º 5
0
 public virtual bool Contains(KeyValuePair <TKey, TValue> item)
 {
     LockQ.EnterReadLock();
     try
     {
         return(dict.Contains(item));
     }
     finally
     {
         LockQ.ExitReadLock();
     }
 }
Exemplo n.º 6
0
 public void CopyTo(TValue[] tasks)
 {
     LockQ.EnterReadLock();
     try
     {
         Array.Copy(dict.valuesArray, tasks, dict.Count);
     }
     finally
     {
         LockQ.ExitReadLock();
     }
 }
 /// <summary>
 ///   This is a blind remove. Prevents the need to check for existence first.
 /// </summary>
 /// <param name = "key">Key to remove</param>
 public void RemoveSafe(TKey key)
 {
     LockQ.EnterReadLock();
     try
     {
         if (dict.ContainsKey(key))
         {
             LockQ.EnterWriteLock();
         }
         try
         {
             dict.Remove(key);
         }
         finally
         {
             LockQ.ExitWriteLock();
         }
     }
     finally
     {
         LockQ.ExitReadLock();
     }
 }