diff --git a/SmartThreadPool/SynchronizedDictionary.cs b/SmartThreadPool/SynchronizedDictionary.cs index 0cce19f..9572a58 100644 --- a/SmartThreadPool/SynchronizedDictionary.cs +++ b/SmartThreadPool/SynchronizedDictionary.cs @@ -1,4 +1,5 @@ using System.Collections.Generic; +using System.Linq; namespace Amib.Threading.Internal { @@ -45,7 +46,11 @@ public TValue this[TKey key] { lock (_lock) { - return _dictionary[key]; + if (_dictionary.TryGetValue(key, out TValue value)) + { + return value; + } + return default; } } set @@ -57,24 +62,24 @@ public TValue this[TKey key] } } - public Dictionary.KeyCollection Keys + public List Keys { get { lock (_lock) { - return _dictionary.Keys; + return _dictionary.Keys.ToList(); } } } - public Dictionary.ValueCollection Values + public List Values { get { lock (_lock) { - return _dictionary.Values; + return _dictionary.Values.ToList(); } } }