Replies: 3 comments 22 replies
-
Tagging subscribers to this area: @dotnet/area-system-collections Issue DetailsDescriptionIf 2 processes call TryAdd on the same dictionary TryAdd will throw the Exception on the second one
Reproduction StepsCreate a dictionary Expected behaviorTryAdd should not throw any Exceptions besides Actual behaviorTryAdd throws Regression?No response Known WorkaroundsNo response Configuration
Other informationThere should be a catch which returns false in the TryAdd method
|
Beta Was this translation helpful? Give feedback.
-
That's because |
Beta Was this translation helpful? Give feedback.
-
up, any way default impls are supported in default extensions? this is really bothering ina big codebase where the actual impl type cannot be propagated for good reasons |
Beta Was this translation helpful? Give feedback.
-
Description
If 2 processes call TryAdd on the same dictionary TryAdd will throw the Exception on the second one
Reproduction Steps
Create a dictionary
IDictionary<string, object> Dict = new ConcurrentDictionary<string, object>();
Start two tasks that call TryAdd onto that dictionary at the same time
Expected behavior
TryAdd should not throw any Exceptions besides
ArgumentNullException
Actual behavior
TryAdd throws
System.ArgumentException: The key already existed in the dictionary.
Regression?
No response
Known Workarounds
No response
Configuration
.NET 7.0
Windows 10 Enterprise / Windows 10 IoT / Windows Server 2016 Standard
x64
I don't think so
newest release of chrome
Other information
There should be a catch which returns false in the TryAdd method
Beta Was this translation helpful? Give feedback.
All reactions