Sorry for the late reply.
I came across a situation where I have to deal with the order of event handlers.
I have a form, and when I click the button on the form, the object is added to the collection somewhere in my code.
The collection has an "Added" event, and two delegates are connected to it. One method deletes any item that has just been added to the collection, while the other displays a message to the user.
If I have some code examples, when the event fires, an "IndexOutOfRange" exception is thrown:
What this script will do correctly is that the ShowMessage_After_CollectionItemAdded method must be started first , and then it will be the DeleteItem_After_CollectionAdded method.
Although at first we can + = the ShowMessage ... method, sometimes we cannot predetermine this sequence until runtime .
liunate Jul 08 '09 at 13:56 2009-07-08 13:56
source share