I have
public delegate void AdministrationEventHandler(object sender, AdministrationEventArgs e);
public static event AdministrationEventHandler MainAdministrationEventHandler;
It’s main event handler in my wcf service.
I have also
private void MyEventHandler(object sender, AdministrationEventArgs e)
{
//code
}
I add new element
AdministrationEventHandler userToAddEventHandler = new AdministrationEventHandler(MyEventHandler);
and then
MainAdministrationEventHandler += userToAddEventHandler;
In my Broadcast() method I call MyEventHandler to each handler.
I’d like to call Broadcast() according to the AdministrationEventArgs e argument.
I tried to make something like list of MainAdministrationEventHandler and call Broadcast() for appropiate element of this list, but it doesn’t work.
I’m getting all handlers by MainAdministrationEventHandler.GetInvocationList()
Is it possible to check e argument after getting it in GetInvocationList()?
Or how can I in other way call Broadcast() to suitable handlers?
What’s a suitable handler? Because based on your code you can only assign handlers of type
AdministrationEventHandlerto that event.Also, the list returned from
GetInvocationList()only contains the handlers to invoke. They haven’t been invoked yet this time around, and you need to invoke them and passeto them.Something like this should do: