Sep 16, 2008 at 3:19 PM
Edited Sep 16, 2008 at 3:20 PM
The current implementation of the
Event Aggregation service uses a List<IEventSubscription> collection to store the event subscriptions. Every time that you add new subscription, this is added to the end of the collection. When the event is published, the
Subscriptions collection is iterated from the end to the beginning. So the last event subscription is usually the first to be published.
However the execution order of the subscriptions is
not guaranteed. For example is you subscribe to an event in the UIThread you could not be sure when the event will be executed (the event is executed asynchronously using the
BeginInvoke method of the Dispatcher).
You should not be dependant of the execution order of the events. If you need to specify a predefined order, you could chain the event subscriptions/publications in different
events (i.e. PreLoginEvent, PostLoginEvent).
You should also note that you should not modify the payload and assume that it will be modified when it reaches the next subscriber or when execution returns to the publisher,
as the approach of the Event Aggregation service is Fire-and-forget (specifically if you dispatch on something different than the publisher thread, these will be invoked asynchronically).
Please, let me know if it helps.