I am not sure whether this is possible, so here me out:
I have a sequence of action to perform multiple
async Task MethodA(...)
{
// some code
Of course, simply invoke the func
, get back a task, and await
it:
async Task Method(Func<Task<Entity>> func)
{
// some code
var a = await func();
// some code
}
Also, when you're sending that lambda expression, since all it's doing is calling an async
method which in itself returns a task, it doesn't need to be async
in itself:
Method(() => CallToIOBoundTask(params));
That's fine as long as all these calls return Task<Entity>
. If not, you can only use Task
(which means starting the operation and awaiting its completion) and you won't be able to use the result.