I have this function:
static Dictionary KeyValueDictionary = new Dictionary();
static void IncreaseValue(int keyId, int adj
You've just been lucky so far. It's not thread-safe.
From the Dictionary
A
Dictionarycan support multiple readers concurrently, as long as the collection is not modified. Even so, enumerating through a collection is intrinsically not a thread-safe procedure. In the rare case where an enumeration contends with write accesses, the collection must be locked during the entire enumeration. To allow the collection to be accessed by multiple threads for reading and writing, you must implement your own synchronization.