I'm having an interesing problem with CAL and the event aggregator. I am attempting to publish an event when the app is deactivated or activated (application.activated and application.deactivated). Some of my modules have popup boxes that a I
want to hide when the application loses focus.
this is a small code sample below
protected override void OnStartup(StartupEventArgs e)
Deactivated += (s, a) => eventAggregator.GetEvent<AppDeactivatedEvent>().Publish(EmptyPayload.Empty);
Deactivated += (s, a) => Console.WriteLine("Deactivated - in app.xaml");
Activated += (s, a) => eventAggregator.GetEvent<AppActivatedEvent>().Publish(EmptyPayload.Empty);
public void AppDeactivated(EmptyPayload empty)
Console.WriteLine("App Deactivated - Module");
What happens is that when the app loses focus I get the following in the console
Deactivated - in app.xaml
When the App regains focus I get the below
App Deactivated - Module
Any ideas on why the event aggregator would wait until the app regains focus for the event to fire.