With Iterators, the following generic delegate is possible:
public delegate IEnumerable<TOut> MyDelegate<TIn>(TIn param1);
With the new async/await in C# 5.0 CTP, I expect to be able to create the analogous delegate as follows:
public delegate async TOut MyDelegate<TIn>(TIn param1);
I can't find the C# 5.0 spec or any help in this regard. Anyone know how this can be written or if it can't be written and why?
async is an implementation detail, not an interface specification. An
async delegate doesn't make sense.
Any method that returns an "awaitable" (such as
Task<T>) can be used with
So an "asynchronous delegate" would be any delegate type that returns
Task<T> (or any other kind of awaitable). In your case:
public delegate Task<TOut> MyDelegate<TIn, TOut>(TIn param1);