ObservableCollection
-
Saturday, June 09, 2012 7:40 PM
One of the biggest challenges when working with TPL or the Async Lib , is still the fact that for some application (WPF /Silverlight mainly)
you need to show the data as it comes , and not only when the entire process is finished...
this is basic and expected Application behavior , so what are the alternatives to bind to Observable collection and start fill this collection
"on the fly" (as data arrives and being aggregated) since we know that ObservalbeCollection is not Thread safe when it comes to its Add/Remove methods.so ,it seems that we are still having the same issue here , even with the Async Lib.
on one hand we cannot write code like this :List<SomeType> lst = await DoHugeLoadingTask();
ObservableCollection<SomeType> collection = new ObservableCollection<SomeType>(lst)
because , as explained this is not good User experiance.
so my questions are :- just the same as BlockingCollection was supposed to solve a pattern problem in the Parallel word , is there a similar solution to
ObservableCollection - If not , do you suggest to break each and every creation of the item that compose this big ObservableCollection into Async Task ?
this means creating many Tasks for each iteration that creates type of "SomeType" in the above example.
I hope I'm clear enoguh
Tomer - just the same as BlockingCollection was supposed to solve a pattern problem in the Parallel word , is there a similar solution to
All Replies
-
Saturday, June 09, 2012 7:50 PMModerator
WPF in .NET 4.5 (with async) handles this via BindingOperations.EnableCollectionSynchronization (http://msdn.microsoft.com/en-us/library/hh198845(v=vs.110).aspx). This allows you to add items to a collection from a background thread, without worrying about the synchronization.
Reed Copsey, Jr. - http://reedcopsey.com
If a post answers your question, please click "Mark As Answer" on that post and "Mark as Helpful".- Proposed As Answer by Stephen Toub - MSFTMicrosoft Employee, Moderator Monday, June 18, 2012 3:28 PM
- Marked As Answer by Stephen Toub - MSFTMicrosoft Employee, Moderator Monday, June 25, 2012 12:49 AM
-
Thursday, July 26, 2012 12:54 PMthanks Reed , this is highly appreciated.

