Made this a seperate answer for code formatting
Ok so after reading your update I think you want what I describe in the "second case" you simply want
Broadcast<T>("Foo")
where T is a delegate.
Then your consumer will do
Subscribe<T>("Foo",HandlerMethod)
So a producer consumer scenario would look like this
internal static class MessagePump
{
public static void Subscribe<T>(String foo, Action<String> handlerMethod)
{
throw new NotImplementedException();
}
public static void BroadcastMessage<T>(String foo, Action<String> someAction)
{
throw new NotImplementedException();
}
}
public class Producer
{
void SendMessage()
{
MessagePump.BroadcastMessage<Action<String>>("Foo", SomeAction);
}
void SomeAction(String param)
{
//Do Something
}
}
public class Consumer
{
public Consumer()
{
MessagePump.Subscribe<Action<String>>("Foo", HandlerMethod);
}
void HandlerMethod(String param)
{
// Do Something
}
}
This is just something off the top of my head and is a contrived example so take it with a grain of salt. This is nearly exactly what I am doing in the courier framework I posted earlier. You may want to dive into that code to get a more concrete implementation example.
You need to think about how you will manage consumers, how you validate Broadcast and subscriptions and for your specific case how are you going to ensure the delegate you are passing around is invoked correctly? Or do you care?
Does this help?