WPA EventAggregator composite recordings lost

In my Composite WPF application, I have an event that is posted when a user double-clicks on a control. Modules subscribe to an event and, if necessary, perform an action.

This event seems to stop working at random. Sometimes, when I run the application, I can fire the event without any problems, in other cases I can only fire it several times before the modules stop receiving the event.

When I look in the debugger, the CAL EventAggregator still has the event, but the event has no subscription. How does an EventAggregator lose a subscription?

+4
source share
1 answer

It turns out the garbage collector deletes the subscription. I will have to read the insides, but when I replaced

 this.mEventAggregator.GetEvent<SomeEvent>().Subscribe(SomeFunction); 

with

 this.mEventAggregator.GetEvent<SomeEvent>().Subscribe( SomeFunction, ThreadOption.UIThread, true); 

he started to work. UI thread options were not my problem, but for others it may be important to make sure that you are also handling the event in the correct thread.

+4
source

All Articles