I am using an ObservableCollection implementation that allows creating/updating/deleting collection items from a different thread than the UI thread. Everything works fine except than when im updating the collection from the UI, i cant delete its items anymore from the different thread.
The ObservableCollectionEx implementation is taken from : http://geekswithblogs.net/NewThingsILearned/archive/2008/01/16/have-worker-thread-update-observablecollection-that-is-bound-to-a.aspx
Please Help! Thanks
EDIT :
Ok. To clear things up : I'm implementing an ObservableCollection with a context sync. It means that when i add/delete/update an item on the collection, i correspondingly do the same on the ObjectContext. When i checked my exception, i saw that it is raised when invoking the ObjectContext.DeleteObject() method, after the item was updated from the UI thread. So it basically got nothing to do with the ObservableCollection but with the ObjectContext itself. The exception though is identical to the exception i first got when trying to delete item on the collection from another thread (the excecption is : "This type of CollectionView does not support changes to its SourceCollection from a thread different from the Dispatcher thread."
The Plot Thickens....
Many Thanks...
The solution to the above is to perform the delete object on the context within a Dispatcher.Invoke
:
Dispatcher.Invoke(new Action(() =>
{
context.DeleteObject(obj);
}));