ConcurrentDictionary<TKey, TValue>.AddOrUpdate(TKey, Func<TKey, TValue>, Func<TKey, TValue, TValue>) - by Tomáš Jecha

Status : 

  Fixed<br /><br />
		This item has been fixed in the current or upcoming version of this product.<br /><br />
		A more detailed explanation for the resolution of this particular item may have been provided in the comments section.

Sign in
to vote
ID 693563 Comments
Status Closed Workarounds
Type Bug Repros 0
Opened 10/7/2011 5:58:08 AM
Access Restriction Public


If using ConcurrentDictionary, its AddOrUpdate method will call "addValueFactory" method more than once if this method is executed in more threads.

There is this line in documentation:
Adds a key/value pair ... if the key does not already exist, or updates a key/value pair ... if the key already exists.

There should be better documentation of how this works and there must be info, that addValueFactory can be called more than once and its value is not used and added to dictionary in some cases.
Sign in to post a comment.
Posted by ChrisLaMont on 11/18/2012 at 2:23 PM
This is closed, and no update was posted as promised.

The documents haven't been updated. I've needed this information for quite some time now...
Posted by Microsoft on 10/21/2011 at 3:21 PM
Hi, and thank you for your suggestion. I agree that we can better describe how addValueFactory behaves when called from multiple threads. I will put this on my list of content enhancements to consider for a future release of the documentation. I will update you again when the issue is resolved. Thanks again!
Posted by MS-Moderator07 [Feedback Moderator] on 10/9/2011 at 9:39 PM
Thanks for your feedback.

We are rerouting this issue to the appropriate group within the Visual Studio Product Team for triage and resolution. These specialized experts will follow-up with your issue.

Posted by MS-Moderator01 on 10/7/2011 at 6:42 AM
Thank you for your feedback, we are currently reviewing the issue you have submitted. If this issue is urgent, please contact support directly(