Is it better to use the async/await keyword when passing a function to a method?
private async Task<int> DoSomethingAsync(Func<Task<int>> innerMethod) {
DoStuff();
var value = await innerMethod();
return value;
}
private async Task<int> GetValueAsync() {
// do stuff with await
return 5;
}
private async Task RunAsync() {
// Are there any differences between the following:
var resultOne = await DoSomethingAsync(async () => await GetValueAsync());
var resultTwo = await DoSomethingAsync(() => GetValueAsync());
}
Which would be preferred as they both will return the same result?