When we want to pass data to an event subscriber, we use EventArgs (or CustomEventArgs) for this.
.Net provides a build in type EventHandler that uses as a parameter an instance of EventArgs class that is build in as well.
What about cases, when I need to notify a subscriber that some action is over, for example search is over? I don’t want to even use EventArgs, that won’t contain anything.
Is there a build in type for signaling another class, without the need to use empty EventArgs?
You have several options:
EventHandlerand the basicEventArgclass – sure the event is empty, but does this do any harm?event MyDelegateWithoutParams MyEvent;IObservableinstead.Actionto you and call this action.I hope one of these options is to your liking. I use 1 and 4 for this kind of situation (4 mostly, if there will be only one "listener").
PS: I guess 2 won’t conform to the .NET framework guidelines, so maybe that one is not the best idea 😉