I read alot about async/await
, but I still have some lack in understanding the following situation.
My question is, should I implement my "wrapper" methods as in DoSomething()
or like in DoSomethingAsync()
.
So what's better (and why): Do I use await
in wrapper methods or return the Task directly?
public static async void Main()
{
await DoSomething();
await DoSomethingAsync();
}
private static Task DoSomething()
{
return MyLibrary.DoSomethingAsync();
}
private static async Task DoSomethingAsync()
{
await MyLibrary.DoSomethingAsync().ConfigureAwait(false);
}
public class MyLibrary
{
public static async Task DoSomethingAsync()
{
// Here is some I/O
}
}