I have a 2-level nested dictionary:
Dictionary<int, Dictionary<int, string>> MyOriginalDict
I need to update the above string values.
I created a copy of the above dictionary and I iterate through this copy using foreach and for every level-2 key, I call a function which updates the value corresponding to it in the main dictionary.
I use ThreadPoolLoader to call the above function. Around 500 threads are created which independently update the original dictionary using ContainsKey() to update the correct value. No new values are added and no two threads update the same key-value.
There are no errors thrown and function calculation is correct. However, it seems the string values updated in the Original dictionary are randomly assigned. It's like ContainsKey() is not working - the values are updated randomly.
Where am I going wrong? Note: If I do the above in a single thread and simply update each string value in a foreach loop, it all works fine but takes several minutes to run.
Thanks.