Quantcast
Channel: Windows Presentation Foundation (WPF) forum
Viewing all articles
Browse latest Browse all 18858

ObservableCollection and Thread Safety

$
0
0
I have a thread safe implementation of the ObservableCollection that locks when adding, removing and firing the CollectionChanged event (in case a listener would like to iterate it).

Now I'm wondering, if a control (like ListView) that binds to this collection migth initiate an enumeration without recieving the CollectionChanged event, iterating it without locking it.
Is there a way to make sure this doesn't happen, or do I have to implement the IEnumerable interface myself, and return the enumerator of a copy of the collection in the GetEnumerator method.

Troels

Viewing all articles
Browse latest Browse all 18858

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>