让我们考虑一些方法:
public static void FireAsyncAndForget(Func<Task> func)
{
JoinableTaskFactory.RunAsync(func).FileAndForget();
}
async Task DoAsync()
{
await SomeOtherMethodAsync();
}
下面的3个示例在代码执行方面有什么区别吗?
FireAsyncAndForget(DoAsync);
FireAsyncAndForget(() => DoAsync());
FireAsyncAndForget(async () => await DoAsync());