Defending against race conditions in System.Collections.Concurrent.ConcurrentDictionary
问题 The .NET ConcurrentDictionary is susceptible to a race condition that may cause unexpected data as explained at the bottom of this MSDN article. I'm assuming that there are several factors to take into account. Q: How should I write code that is not vulnerable to that race condition that may cause data loss? In my scenario I have an input stream that has an always increasing index (n++). My thought is that I could detect missing data if the race condition occurs and re-send it. On the other