When you subscribe to an event in .NET, the subscription is added to a multicast delegate. When the event is fired, the delegates are called in the order they were subscribed.
I’d like to override the subscription somehow, so that the subscriptions are actually fired in the reverse order. Can this be done, and how?
I think something like this might be what I need?:
public event MyReversedEvent
{
add { /* magic! */ }
remove { /* magic! */ }
}
Controlling When and If a Delegate Fires Within a Multicast Delegate
The following method creates a multicast delegate called allInstances and then uses GetInvocationList to allow each delegate to be fired individually, in reverse order: