This link, http://msdn.microsoft.com/en-us/vcsharp/bb508935.aspx, has more information about event handlers and the order in which they are called. The order is not specified in the CLR reference and therefore you should not depend on a specific order.
From: [email protected] [mailto:[email protected]] On Behalf Of Curt Hagenlocher Sent: Monday, June 07, 2010 2:41 PM To: Discussion of IronPython Subject: Re: [IronPython] WPF/IronPython event handlers question - multiple event handlers These are CLR-level issues. The first basically comes down to the fact that there's really no way to enumerate the handlers which have already been added to an event. As for the second, there is no contract that defines the order on which the handler will be called. But I suspect that the default implementation of an event -- which corresponds to just declaring "public event EventHandler MyEvent;" in C# -- would probably give consistent in-order results. On Mon, Jun 7, 2010 at 1:26 PM, Ken MacDonald <[email protected]<mailto:[email protected]>> wrote: Hi, I've got a whole stack of event handlers, assigned via the usual something like.... my_button.Click += button_was_clicked As it turns out, the initialization for the thing that has all these handlers may need to be run several times, and it seems like I ended up with multiple copies of the same event handler, and "button_was_clicked()" now gets invoked multiple times for EACH time I click my_button. It seems to be solved by just skipping the handler assignment if I've already done it before, but it seems odd that the same EH would be assigned and fired twice. Is this really what I'm seeing? I can see a case for assigning multiple different EH's: my_button.Click += event_handler_1 my_button.Click += event_handler_2 but then this begs the question, is there a defined order in which the EH's will fire? I looked thru multiple python/IronPython books and googled, but came up empty on both questions..... Hopefully someone here understands these things better than I do.... Ken _______________________________________________ Users mailing list [email protected]<mailto:[email protected]> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
_______________________________________________ Users mailing list [email protected] http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
