Suppose I have a method as follows...
public static async Task DoIt(Func<Task> doit) {
// Do something first
await doit();
// Do something last
}
I can pass in an awaitable function as follows...
await DoIt(() => Task.Delay(1000));
If I want to pass in something non-awaitable, I can do it like this...
_ = DoIt(() => Task.Run(() => Console.WriteLine("Hi")));
...but this seems quite ugly. Is there a neater way of doing this?