I would not suggest you have a delegate that returns some value. There is a better approach to getting some value from a method when it is executed with its execution, that is, using the "out" parameters.
In your case, you may have something like the code below:
public delegate void DoThisWithReturn(out bool returnValue);
public static void DoThisMethod(out bool returnValue)
{
returnValue = true;
}
public static void Start()
{
var delegateInstance = new DoThisWithReturn(DoThisMethod);
bool returnValue;
var asyncResult = delegateInstance.BeginInvoke(out returnValue, null, null);
delegateInstance.EndInvoke(out returnValue, asyncResult);
var valueRecievedWhenMethodDone = returnValue;
}
source
share