← Back to context

Comment by billpg

3 years ago

"Suppose I'm trying to allow multiple threads access to a Dictionary object."

"You should use a ConcurrentDictionary."

"Okay, but I'm actually asking about ways the compiler could help out with code duplication. I'm not actually trying to protect a Dictionary object."

"A ConcurrentDictionary would fix that."

"What I'm looking for is some way the C# compiler could help adding a wrapper to many functions. The Dictionary object was just an example."

"I've read your problem and you should use a ConcurrentDictionary."

(Screams in XY.)

https://stackoverflow.com/q/52312822/3568

There were 2 suggestions for the asker to use ConcurrentDictionary before the asker clarified, and 1 more afterwards (probably because the answerer didn't read through the whole thread).

Other than that one response, this looks like a very constructive back-and-forth (which could've been way shorter if the asker presented his case accurately without exaggerating it), so I don't really see what's wrong with it.