I announced a dictionary of dizianaria:
Dictionary<String, Dictionary<String, String>> values;
I have a getter to get a dictionary at a specific index:
public Dictionary<String,String> get(String idx) { lock (_lock) { return values[moduleName]; } }
As you can see, I work in a multi-threaded environment. My question is: I need to return a copy of my dictionary in order to be thread safe:
public Dictionary<String,String> get(String idx) { lock (_lock) { return new Dictionary<string, string>(values[moduleName]); } }
If I donโt, the class calling getter will get a copy (so if I remove this dictionary from my Dictionary<String, Dictionary<String, String>> , will it still work)?
Greetings
Thierry.
source share