Why isn't it possible to update an ObservableCollection from a different thread?

Posted by MainMa on Stack Overflow See other posts from Stack Overflow or by MainMa
Published on 2010-06-05T14:04:09Z Indexed on 2010/06/05 14:12 UTC
Read the original article Hit count: 196

In a multi-threaded WPF application, it is not possible to update an ObservableCollection from a thread other than WPF window thread.

I know there are workarounds, so my question is not how to avoid the "This type of CollectionView does not support changes to its SourceCollection from a thread different from the Dispatcher thread" exception.

My question is, why there is such an exception? Why wasn't it possible to allow collection updates from any thread?

Personally, I don't see any reason to block UI update when ObservableCollection is changed from other threads. If two threads (including parallel ones) are accessing the same object, one listening for changes of object properties through events, the other one doing changes, it will always work, at least if locks are used properly. So, what are the reasons?

© Stack Overflow or respective owner

Related posts about c#

Related posts about wpf