rifter1818 Posted March 30, 2004 Posted March 30, 2004 If i have an event with multiple handlers, how can i controll which handler is called first (or actually most important last). The context is this, i am programming an RPG and i want to have a message center, the mainmodule Raises a RENDER event when it is ready to render (pretty simple), two modules controll this event one is the Message center and the other could be one of 4 depending opon the game state (Menu,World,City,Battle) these change by having an addhandler/remove handler system execute whenever the gamestate property changes. What i want is for the Message center to be rendered last at all times. Quote
Leaders Iceplug Posted March 30, 2004 Leaders Posted March 30, 2004 Why don't you just add one handler to one procedure and have that event procedure call the event that you originally wanted to be called with the second handle? I would assume that the event handler that is assigned first will be called first. (I've never tried it though) Quote Iceplug, USN One of my coworkers thinks that I believe that drawing bullets is the most efficient way of drawing bullets. Whatever!!! :-(
Joe Mamma Posted April 7, 2004 Posted April 7, 2004 If i have an event with multiple handlers' date=' how can i controll which handler is called first (or actually most important last). The context is this, i am programming an RPG and i want to have a message center, the mainmodule Raises a RENDER event when it is ready to render (pretty simple), two modules controll this event one is the Message center and the other could be one of 4 depending opon the game state (Menu,World,City,Battle) these change by having an addhandler/remove handler system execute whenever the gamestate property changes. What i want is for the Message center to be rendered last at all times.[/quote'] might I suggest staged events. . . have PreRendering, Rendering and PostRendering events. . . PreRendering Events are consumed by all objects that need to be cofigured before rendering. . . Rendering are consumed in a DoRender method Call and are sequence inspecific. and PostRendering are consumed only after a succesful call to DoRender protected virtual void DoRender { // Actual Rendering Code here if (Rendering != null) Rendering(this, EventArgs.Empty); } public void Render { if (PreRendering != null) PreRendering(this, EventArgs.Empty); DoRender(); if (PostRendering != null) PostRendering(this, EventArgs.Empty); } many object have BeforeChange, Changing and After Change events. . . a similar design. you could even define your own Event Args class to pass back usefull information Quote Joe Mamma Amendment 4: The right of the people to be secure in their persons, houses, papers, and effects, against unreasonable searches and seizures, shall not be violated, and no warrants shall issue, but upon probable cause, supported by oath or affirmation, and particularly describing the place to be searched, and the persons or things to be seized. Amendment 9: The enumeration in the Constitution, of certain rights, shall not be construed to deny or disparage others retained by the people.
TechnoTone Posted April 7, 2004 Posted April 7, 2004 might I suggest staged events. . . have PreRendering, Rendering and PostRendering events. . . Nice. I wouldn't have thought of that. Quote TT (*_*) There are 10 types of people in this world; those that understand binary and those that don't.
rifter1818 Posted April 7, 2004 Author Posted April 7, 2004 Thanks I think i might just set up those events. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.