EventAggregator Monitor?

Topics: Prism v4 - WPF 4
Dec 1, 2011 at 6:19 PM

Does anybody know of any way to monitor all of the events going through the EventAggregator at runtime?

I understand how to subscribe to each event type, but that would require knowledge of the events.  What I am looking for would just show the traffic independent of the event type.



Dec 2, 2011 at 3:24 PM


Based on my understanding, you could monitor events in the EventAggregator, for example by modifying the Subscribe method in the CompositePresentationEvent Class of the Prism Library, this way you could be notified when events are being subscribed and the corresponding handler for them. A sample of this can be seen in the following code snippet:

public virtual SubscriptionToken Subscribe(Action<TPayload> action, ThreadOption threadOption, bool keepSubscriberReferenceAlive, Predicate<TPayload> filter)


            var subscriptionInfo = "Event " + this.GetType().ToString() + " subscribed (handler is " + action.Target.GetType() + "." + action.Method.Name + ")";

            ServiceLocator.Current.GetInstance<ILoggerFacade>().Log(subscriptionInfo, Category.Debug, Priority.High);


Also you could modify the InternalPublish method in the EventBase Class of the Prism Library to be notify when an event is being published, the payload used and the number of handlers for example. This can be achieved like in the following code snippet:

protected virtual void InternalPublish(params object[] arguments)

            List<Action<object[]>> executionStrategies = PruneAndReturnStrategies();

            var publicationInfo = "Event " + this.GetType().ToString() + " published (payload: " + (arguments[0] ?? "null") + ", " + executionStrategies.Count + " handlers)";

            ServiceLocator.Current.GetInstance<ILoggerFacade>().Log(publicationInfo, Category.Debug, Priority.High);

            foreach (var executionStrategy in executionStrategies)

Note that this modifications will be useful for debugging purposes, as the notifications will be shown in the Debug Output Window.

Also you can find a small sample application in my Skydrive Account under the name EventAggregatorMonitorSample that portrays the aforementioned modifications.

I hope you find this useful

Agustin Adami

Dec 2, 2011 at 3:34 PM

Neat, thank you very much.