3

Moved some ops into a background thread and promptly ran into the UI exception where a UI control is bound to a ObservableCollection

.net 4.5 has this solved via the new BindingOperations.EnableCollectionSynchronization()

however can't migrate to 4.5 yet so hoping there's something for the .net 4.0 world to make ObservableCollection thread-safe ?

Kumar
  • 10,997
  • 13
  • 84
  • 134
  • 2
    Just don't update the ObservableCollection from a background thread. Invoke your inserts and deletes. – Chris Shain Oct 18 '12 at 23:43
  • would like to avoid refactoring in anticipation of eventual move to .net 4.5, hoping for a simpler way out ! – Kumar Oct 18 '12 at 23:48
  • 4.5 is going to do the same thing when you use EnableCollectionSynchronization. It's just doing it for you, more or less. It's probably still considered bad practice to rely on the binding to marshal it for you- you should be managing that yourself. – Chris Shain Oct 18 '12 at 23:53
  • looking for simplicity/readable code here ! await/async is but syntactic sugar over TPL but that's still one of the most awaited features no ? – Kumar Oct 19 '12 at 00:00

0 Answers0