From b60b864aca401bb1355c3e4162a9d6f5ce32cffb Mon Sep 17 00:00:00 2001 From: JustArchi Date: Fri, 13 May 2016 19:43:48 +0200 Subject: [PATCH] Misc --- ArchiSteamFarm/ConcurrentHashSet.cs | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/ArchiSteamFarm/ConcurrentHashSet.cs b/ArchiSteamFarm/ConcurrentHashSet.cs index dfa320354..9f1bd39a7 100644 --- a/ArchiSteamFarm/ConcurrentHashSet.cs +++ b/ArchiSteamFarm/ConcurrentHashSet.cs @@ -34,9 +34,20 @@ namespace ArchiSteamFarm { private readonly ReaderWriterLockSlim Lock = new ReaderWriterLockSlim(LockRecursionPolicy.SupportsRecursion); public bool IsReadOnly => false; - public IEnumerator GetEnumerator() => new ConcurrentEnumerator(HashSet, Lock); + public int Count { + get { + Lock.EnterReadLock(); + + try { + return HashSet.Count; + } finally { + Lock.ExitReadLock(); + } + } + } + [SuppressMessage("ReSharper", "UnusedMethodReturnValue.Global")] public bool Add(T item) { Lock.EnterWriteLock(); @@ -89,18 +100,6 @@ namespace ArchiSteamFarm { } } - public int Count { - get { - Lock.EnterReadLock(); - - try { - return HashSet.Count; - } finally { - Lock.ExitReadLock(); - } - } - } - public void Dispose() { if (Lock != null) { Lock.Dispose(); @@ -121,4 +120,4 @@ namespace ArchiSteamFarm { IEnumerator IEnumerable.GetEnumerator() => GetEnumerator(); } -} \ No newline at end of file +}