❔ Help with Action syntax for event handler system

I am trying to add a basic event system to my program and would like the syntax to be something like this:

RegisterEventHandler<EventHandler, MyEvent>(x.Process);


Ideally there is no need for a baseclass or interface. All that should be needed is for the function passed as an action to take the event type as an argument.
I have the following implmentation for the registration:

void RegisterEventHandler<THandler, TEvent>(Action<THandler, TEvent> action)


I would very much like the register syntax to be like this:
RegisterEventHandler<EventHandler, MyEvent>(x.Process);

but I struggle with how to achive this, and I am not entirely sure if its possible?
Was this page helpful?