Search code examples
prismmef

Migrate MEF code for CompositePresentationEvent to PubSubEvent


I basically try to migrate my MEF code from Prism 4.0 to Prism 6.1.0 so first problem I ran into there was no CompositePresentationEvent anymore so I changed it to PubSubEvent. This gives me the a new exeption

To use the UIThread option for subscribing, the EventAggregator must be constructed on the UI thread.

so the way you could export and import the CompositePresentationEvent with MEF made no use of a EventAggregator instance at all you simple imported the event and MEF did the job.

So simple question is there some sort of best practice for migrate this kind of code or is it just simpler to stick with prism 4 ?

Regards


Solution

  • it's a little late but if someone was wondering what has been done in the end ...

    in short, refactoring to use IEventAggregator but still using MEF to import/export a single instance of the EventAggregator.