Despite the game not using async stuff (apart from minion AI which is not enabled publicly anywhere), Unity or Mono still causes occasional rare IndexOutOfRangeExceptions when trying to merely Add an entry to a Dictionary, even though the game is supposed to be thread-safe.
ConcurrentDictionary is thread-safe, but does not offer the same method APIs as Dictionary.
I am wondering if switching to ConcurrentDictionary in the code (400+ instances of it) would help. Could implement some extension methods to mimic the Dictionary.Add calls. But not sure this is worth refactoring.
Dictionary is not thread-safe.
Despite the game not using async stuff (apart from minion AI which is not enabled publicly anywhere), Unity or Mono still causes occasional rare IndexOutOfRangeExceptions when trying to merely Add an entry to a Dictionary, even though the game is supposed to be thread-safe.
ConcurrentDictionary is thread-safe, but does not offer the same method APIs as Dictionary.
I am wondering if switching to ConcurrentDictionary in the code (400+ instances of it) would help. Could implement some extension methods to mimic the
Dictionary.Add
calls. But not sure this is worth refactoring.