How do you implement an async action delegate method?

The async equivalent of Action<T> is Func<T, Task>, so I believe this is what you’re looking for:

public async Task<T> DoSomethingAsync<T>(Func<T, Task> resultBody)
    where T : Result, new()
{
  T result = new T();
  await resultBody(result);
  return result;
}

Leave a Comment