Since event handlers are called in the order in which you add them, based on the code that I see in your question, you cannot call the mynewclass handler first. The event handler created by MyClass is always added first.
One solution would be priority management for event handlers. Instead of using the built-in event handler + = / - = operators instead, you should have methods to add and remove events, where you can explicitly specify the order. That way, if the class knows that it needs to handle the event first, it can ask for it. However, be careful because you can easily run into a situation where several classes insist that they handle the event first.
Here is some quick and dirty code to get you started:
class MyClass { private LinkedList<MyEventHandler> eventHandlers; public enum Ordering { First, Last, ... }; public void AddHandler(MyEventHandler handler, Ordering order) { switch(order) { case Ordering.First: eventHandlers.AddFirst(handler); break;
source share