I have a concurrent dictionary which is a class variable:
private readonly ConcurrentDictionary<Id, int> _tracker=
new ConcurrentDictionary<Id, int>(Id.EqualityComparer);
I'm incrementing it in a method as follows:
_tracker[id]++;
Is this safe to do so if the _tracker
will be accesed concurrently? Or should I be using the
_tracker.AddOrUpdate(id, 1, (id, count) => count+ 1);