We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent b5e2bfc commit 5116b03Copy full SHA for 5116b03
src/Files.Shared/Extensions/LinqExtensions.cs
@@ -1,4 +1,5 @@
1
using System;
2
+using System.Collections.Concurrent;
3
using System.Collections.Generic;
4
using System.Linq;
5
using System.Threading.Tasks;
@@ -53,7 +54,14 @@ public static class LinqExtensions
53
54
var defaultValue = defaultValueFunc();
55
if (defaultValue is Task<TValue?> value)
56
{
- dictionary.Add(key, value);
57
+ if (dictionary is ConcurrentDictionary<TKey, Task<TValue?>> cDict)
58
+ {
59
+ cDict.TryAdd(key, value);
60
+ }
61
+ else
62
63
+ dictionary.Add(key, value);
64
65
}
66
return defaultValue;
67
0 commit comments