Locked 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

All Replies