I need to support functionality that updates two concurrent dictionaries (on create, update, delete).
Each operation (update, delete, create) uses two of them and should be atomic. What is the best way to do that in .NET C#.
I need to support functionality that updates two concurrent dictionaries (on create, update, delete).
Share
The easiest way would be to use a lock:
PLEASE NOTE: Locking the “writing” operations on the dictionaries is not enough! You will also need to synchronize reading of the dictionary to avoid the case when you try to get a value from the dictionary, which is currently being accessed by one of the update methods.