I'll take a look a the EventAggregator - it sounds like a nice solution for these types of situtations. I had thought of it as a UI command/message routing type of system, not used for data, but I can see now that it makes a lot of sense for data.
In the meantime, the issue I'm having is with the following code (cleaned up for clarity)
ThreadStart start = delegate()
{
// repository is declared as a class field
// This is the code that takes a while to run (~30 seconds)
_entityRepository = new EntityRepository();
Dispatcher.CurrentDispatcher.Invoke(new Action(delegate()
{
_allEntites.Clear();
foreach (var v in _entityRepository.GetEntities())
{
_allEntites.Add(v);
}
}));
};
var threader = new Thread(start);
threader.Start();
The problem is, I get the exception "This type of CollectionView does not support changes to its SourceCollection from a thread different from the Dispatcher thread.". It would appear that the CurrentDispatcher is not getting the same Thread, which makes sense, as I'm calling CurrentDispatcher from within the newly spun up thread.
Thanks,
Erick