I'm passing a System.Action as a parameter to a method which does some lengthy operation and want to add more stuff to the invocation list after the Action has been passed:
class Class1
{
private System.Action onDoneCallback;
void StartAsyncOperation(System.Action onDoneCallback)
{
this.onDoneCallback = onDoneCallback;
// do lengthy stuff
}
void MuchLater()
{
this.onDoneCallBack?.Invoke();
}
}
class Class2
{
public System.Action action;
void DoStuff()
{
action += () => print ("a");
new Class1().StartAsyncOperation(action);
}
{
// ... much later in another …Run Code Online (Sandbox Code Playgroud)