It depends, in my case I prefer to use this method.
ConcurrentDictionary<TKey, TValue>.AddOrUpdate Method (TKey, Func<TKey, TValue>, Func<TKey, TValue, TValue>);
See the MSDN Library for more information.
Sample Usage:
results.AddOrUpdate( Id, id => new DbResult() { Id = id, Value = row.Value, Rank = 1 }, (id, v) => { v.Rank++; return v; });
Onur Nov 30 '15 at 13:09 on 2015-11-30 13:09
source share