Event handling C# / Registering a callback
- by Jeff Dahmer
Events can only return void and recieve object sender/eventargs right?
If so then craptastic.... how can I pass a function pointer to another obj, like:
public bool ACallBackFunc(int n)
{
return n > 0;
}
public void RegisterCallback(Something s)
{
s.GiveCallBack(this.ACallBackFunc);
}
Something::GiveCallBack(Action? funcPtr)
I tried using Action, but I need it to return some value and Actions can only return void. Also, we do not know what kind of a callback we will be recieving; it could return anything and have any params! Reflection will have to be used somehow I reckon.