I'm using between 8-16 threads to write to a .Net 4.0 ConcurrentDictionary collection, and it works great. However I have read that during an enumeration, an update may occur, meaning the enumeration doesn't reflect the full dictionary. I have an enumeration thread which fires every 5 seconds on a timer, to clean, i.e. remove ConcurrentDictionary old items. I want to halt the write/updates to the concurrent dictionary, so the enumerator works as I want.

What would be the best synchronization mechanism for this. I did look at using AutoResetEvent with a timeout, but with the wait and set mechanism potentially waiting for 5 seconds to send the signal to the other 8 threads restart updates.

Any ideas would be helpful. I know the knowledge base for the new .Net 4 TPL is still not that big, so any help would be appreciated.

Bob.