Events
-
Can i attach multiple functions to an event Handler/listner? If so is there anyway to prioritize their execution? Also what would happen if you trigger an event with no handler attached? ty
If you trigger an event with no handler, then nothing gets done about it. Make a button with no OnClick handler, and nothing happens when the button is clicked. As for multiple functions, yes you can. When you add a handler to an event you use
+=
so just+=
another function. As for priority, im not sure. I assume that the first function you added will be executed first, but that may not be the case.My current favourite word is: Nipple!
-SK Genius
-
Can i attach multiple functions to an event Handler/listner? If so is there anyway to prioritize their execution? Also what would happen if you trigger an event with no handler attached? ty
Additionally to what SK Genius already said, why not just create a method that will call all methods in the priority you like to be called without depending on the order in which they were registered? Something like
someclass.Event += new EventHandler(MyFunc);
public void MyFunc(...)
{
Func1();
Func2();
Func3();
}regards
-
Additionally to what SK Genius already said, why not just create a method that will call all methods in the priority you like to be called without depending on the order in which they were registered? Something like
someclass.Event += new EventHandler(MyFunc);
public void MyFunc(...)
{
Func1();
Func2();
Func3();
}regards