OpenMetaverse.ReaderWriterLockSlim.ExitUpgradeableReadLock C# (CSharp) Метод

ExitUpgradeableReadLock() публичный Метод

public ExitUpgradeableReadLock ( ) : void
Результат void
        public void ExitUpgradeableReadLock()
        {
            EnterMyLock();
            Debug.Assert(owners > 0, "Releasing an upgradable lock, but there was no reader!");
            --owners;
            upgradable_thread = null;
            ExitAndWakeUpAppropriateWaiters();
        }

Usage Example

Пример #1
0
        public int RemoveAll(Predicate <TValue> predicate)
        {
            IList <TKey1> list = new List <TKey1>();

            rwLock.EnterUpgradeableReadLock();

            try
            {
                foreach (KeyValuePair <TKey1, TValue> kvp in Dictionary1)
                {
                    if (predicate(kvp.Value))
                    {
                        list.Add(kvp.Key);
                    }
                }

                IList <TKey2> list2 = new List <TKey2>(list.Count);
                foreach (KeyValuePair <TKey2, TValue> kvp in Dictionary2)
                {
                    if (predicate(kvp.Value))
                    {
                        list2.Add(kvp.Key);
                    }
                }

                rwLock.EnterWriteLock();

                try
                {
                    for (int i = 0; i < list.Count; i++)
                    {
                        Dictionary1.Remove(list[i]);
                    }

                    for (int i = 0; i < list2.Count; i++)
                    {
                        Dictionary2.Remove(list2[i]);
                    }
                }
                finally { rwLock.ExitWriteLock(); }
            }
            finally { rwLock.ExitUpgradeableReadLock(); }

            return(list.Count);
        }
All Usage Examples Of OpenMetaverse.ReaderWriterLockSlim::ExitUpgradeableReadLock