There's a concurrent dictionary, which is collecting information from different sources and once in a minute is supposed to get refreshed and pass collected data to another handler.
var currentDictionarySnapshot = _currentDictionary;
_currentDictionary = new ConcurrentDictionary<int, string>();
return new ReadOnlyDictionary<int, string>(currentDictionarySnapshot);
What I need is to make currentDictionarySnapshot
wait for all threads that have reference on it to finish writing and create new ReadOnlyDictionary
just after.
Does ConcurrentDictionary
support it natively or how can I provide this if it doesn't?