Saturday, 25 October 2008

WPF Cross-Thread Collection Binding

From the rather excellent QuantumBit Designs there are a series of articles about multithreading and collections.

The "grand solution" can be found here: WPF Cross-Thread Collection Binding - Part 4 - The Grand Solution

Features
-Allows WPF to bind to a collection that is modified from any thread
-Allows WPF to bind to properties of items in the collection that are modified from any thread
-No lock required if used from a single worker thread
-Relatively simple (compared to some other attempts)
-Non-blocking

Downsides
-Requires two lists internally
-The ObservableCollection list should not be modified
-Disposable or DependencyObjects should not be used

I've implemented the ObservableList in the test project InABind but we haven't confirmed the overhead involved of using ObservableList in place of ObservableCollection.

No comments: