Monday, September 29, 2014

How to get all the return value of delegate.

If you want to get separated values from the delegate you need to check GetInvocationList, so the code may look like that:



foreach (var meth in MyDelegate.GetInvocationList())
{
bool b = await ((Func<Task<bool>>)meth)();
}



However i think that it looks nasty and i have never uses delegates with multiple methods with return value other than void. It is not advisable.


No comments:

Post a Comment