When working with a concurrent collection (for example ConcurrentDictionary) should I use TryAdd method, or just a plain old index assignment? I mean, do TryAdd method blocks when adding, so if another thread would try to remove the value it would have to wait until add is complete?
The prefix try
has nothing to do with thread safety. It is just exception-free version of Add
.