I have a class, EventContainer.cs, which contains an event, say:
public event EventHandler AfterSearch;
I have another class, EventRaiser.cs. How do I raise (and not handle) the above said event from this class?
The raised event will in turn call the handler of the event in the EventContainer class. Something like this (this is obviously not correct):
EventContainer obj = new EventContainer();
RaiseEvent(obj.AfterSearch);
This is not possible, Events can only be risen from inside the class. If you could do that, it would defeat the purpose of events (being able to rise status changes from inside the class). I think you are misunderstanding the function of events – an event is defined inside a class and others can subscribe to it by doing
obj.AfterSearch += handler;(where handler is a method according to the signature ofAfterSearch). One is able to subscribe to the event from the outside just fine, but it can only be risen from inside the class defining it.