Do I need to lock ConcurrentDictionary?
ConcurrentDictionary is designed for multithreaded scenarios. You do not have to use locks in your code to add or remove items from the collection. However, it is always possible for one thread to retrieve a value, and another thread to immediately update the collection by giving the same key a new value.
Is Ienumerable thread safe?
As long as you are certain that the List will never be modified then it will be safe to read from multiple threads. This includes the use of the IEnumerator instances it provides.
Can you add another item to observablecollection during collectionchanged?
You cannot add another item to the same ObservableCollection during a CollectionChanged event as this will result in an InvalidOperationException being thrown. You could use the dispatcher to schedule the addition of another item once the event has been handled though:
Which is not a thread safe observablecollection < T >?
The CollectionChanged event is often bound to a UI element which can only be updated from the UI thread. Internally, items are stored in a List which is not thread-safe. Writes during reads or multiple parallel writes can cause the list to become corrupt. The GetEnumerator () methods return an enumerator from the working list.
Can a collectionview change its sourcecollection from a different thread?
This type of CollectionView does not support changes to its SourceCollection from a thread different from the Dispatcher thread. Note that this is not happening from the UI thread, so i don’t have access to the dispatcher.
What does enablecollectionsynchronization do to a thread?
EnableCollectionSynchronizationdoes two things: Remembers the thread from which it is called and causes the data binding pipeline to marshal CollectionChangedevents on that thread.