Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions SmartThreadPool/SynchronizedDictionary.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Collections.Generic;
using System.Linq;

namespace Amib.Threading.Internal
{
Expand Down Expand Up @@ -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
Expand All @@ -57,24 +62,24 @@ public TValue this[TKey key]
}
}

public Dictionary<TKey, TValue>.KeyCollection Keys
public List<TKey> Keys
{
get
{
lock (_lock)
{
return _dictionary.Keys;
return _dictionary.Keys.ToList();
}
}
}

public Dictionary<TKey, TValue>.ValueCollection Values
public List<TValue> Values
{
get
{
lock (_lock)
{
return _dictionary.Values;
return _dictionary.Values.ToList();
}
}
}
Expand Down