I'm writing C# code with Visual Studio. I have a Task-returning function awaited in an async Task method like the following:
async Task AwaitForSomeTask()
{
await DoSomething();
}
I wrote two possible implementations (provided below) of DoSomething()
method. What are the differences between these two implementations? What are the advantages and/or disadvatages of each one?
Task DoSomething()
{
return Task.Run( () => { // Some code } );
}
async Task DoSomething()
{
// Some code
}
Thank you in advance!