?
Solved

an array of events

Posted on 2004-10-12
1
Medium Priority
?
453 Views
Last Modified: 2012-08-13
Hi,

I would like to create an array of events for a project that I'm working on - is this possible?

I'm not talking about having a single event call many handlers - I know how to do that.

Thanks
0
Comment
Question by:bhanley9681
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 3

Accepted Solution

by:
a_goat earned 1600 total points
ID: 12294694
There's no way to directly create an array of events.  You can do it indirectly though:

public class MyEventManager
{
public event EventHandler MyEvent;
}

public class MyFoo
{
public MyEventManager[] OnEvent = new MyEventManager[10];
public MyFoo()
{
for (int I = 0; I < OnEvent.Length; I++)
OnEvent[I] = new MyEventManager();
}
}

Then you can add an event like:

MyFoo Junk = new MyFoo();
Junk.OnEvent[2].MyEvent += [blah blah blah]

You might even be able to do it in a sneakier way, so you don't have to use the "MyEvent" when assigning the event handler
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: Najam
Having new technologies does not mean they will completely replace old components.  Recently I had to create WCF that will be called by VB6 component.  Here I will describe what steps one should follow while doing so, please feel free to post any qu…
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses

764 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question