I am trying to understand this concept, and even after many experiments, I still canβt understand that it is best to use ObservableCollections in WPF and use BindingOperations.EnableCollectionSynchronization.
If I have a viewmodel with an observable collection, and I enable collection synchronization using locking, as shown below:
m_obsverableCollection = new ObservableCollection<..>; BindingOperations.EnableCollectionSynchronization(m_obsverableCollection, m_obsverableCollectionLock);
Does this mean that every modification and listing for this observable collection will:
- Block collection automatically with m_obsverableCollectionLock?
- Marshall all the changes in the thread on which the collection was created?
- Marshall all the changes in the thread on which the bind operation call was made?
When using BindingOperations.EnableCollectionSynchronization, will I ever need to do any locking explicitly?
The problem that caused all this is that even after using BindingOperations.EnableCollectionSynchronization and locking the elements using the same lock, I passed this method, very often I get "This type of CollectionView does not support changes to the SourceCollection from a stream other than Dispatcher thread. " An exception
Ruskin
source share