Jump to content
Xtreme .Net Talk

Recommended Posts

Posted
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.
  • Leaders
Posted

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)

Iceplug, USN

One of my coworkers thinks that I believe that drawing bullets is the most efficient way of drawing bullets. Whatever!!! :-(

Posted
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

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.

Posted
might I suggest staged events. . .

 

have PreRendering, Rendering and PostRendering events. . .

Nice. I wouldn't have thought of that.

TT

(*_*)

 

There are 10 types of people in this world;

those that understand binary and those that don't.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...