I have a similar issue to this post Prism CompositePresentationEvent fires twice
My issue is that the Publish is only firing once but the code in the Subscribe is executing twice.
Here is my publish code.
EventAggregator.GetEvent<PubSubEvent<HardwareLoaded>>().Publish(new HardwareLoaded() { HardwareOK = _HardwareOK });
And the subscribe code.
IEventAggregator.GetEvent<PubSubEvent<HardwareLoaded>>().Subscribe(x =>
{
if (!x.HardwareOK)
{
MessageBox.Show("There was an issue loading hardware. See Log");
}
LoadingVisibility = Visibility.Collapsed;
});
I put a breakpoint at both the Publish and the Subscribe and can see that the publish only fires once but the subscribe code fires twice. This is backed up by the message box showing twice.
I have run a search for any other publish code and found none.
Any ideas?
Make sure the Subscribe method is called only once.
If it is called twice, the same event will trigger the same callback, just as it would if there were completely different handlers reacting to the same event.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With