News:

Happy New Year! Yes, the current one, not a previous one; this is a new post, we swear!

Main Menu

C# Events and such

Started by abc, December 06, 2007, 05:33:27 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

abc

So I'm using a reference called Fluent.Toc in C# for AIM. Well, I have separate classes to handle each of the large functions the bot processes. A class for Math functions, a class for Trivia functions and a class for an 8 ball function. The toc class has those event handlers.


TOCClient.Message += new MessageEventHandler(TOCClient_Message);


then...  I have my event..


protected void TOCClient_Message(object sender, MessageEventArgs MsgEventArgs)
{
         
           
           
}


Well, my question is, how would I let my other classes access my variable "MsgEventArgs"? I need to find out what the message says from the other classes.

Thanks!

EDIT: Would I end up putting the event handler in each of my classes as well?

Camel

I suppose it depends on how you want to structure your program. If they are all going to be internal components, you can probably get away with what you suggested in your edit. If you're trying to create a plugin system, you'll probably want to develop some form of API.

<Camel> i said what what
<Blaze> in the butt
<Camel> you want to do it in my butt?
<Blaze> in my butt
<Camel> let's do it in the butt
<Blaze> Okay!

MyndFyre

You'd probably want to create an event, handle the Fluent.Toc event and bubble it to any listeners to your API.  See my blog entry about C# events (it should be on the first page of this forum) about how to create and activate events.
Quote from: Joe on January 23, 2011, 11:47:54 PM
I have a programming folder, and I have nothing of value there

Running with Code has a new home!

Quote from: Rule on May 26, 2009, 02:02:12 PMOur species really annoys me.

abc