I'm having trouble understanding how to use the lock() statement in my code. I have a couple of static collections:
private static Dictionary<string, User>() Users = new Dictionary<string, User>();
I constantly add, delete, update and read from this collection. I understand that when I add, delete or update, I have to block Users , but when I read from the collection, do I need to block it? What is the correct way to do something like search for a key and return User in the dictionary? I was thinking of creating a new instance of Dictionary and then copying users to it and then reading from it or just reading it directly?
source share