In my understanding, if I await an async function, then the following code will be wrapped in a delegate and executed after the async function returns:
async bool Test()
{
await byte[] arr = ReadAsync(....)
// all following code will be wrapped into a delegate
if (arr != null)
{
// Do something
return true;
}
return false;
}
It sounds like equal to if I explicitly wrap following code in a ContinueWith:
async bool Test()
{
bool res = await ReadAsync(...)
.ContinueWith(t =>
{
byte[] arr = t.Result;
if (arr != null)
{
// Do something
return true;
}
return false;
});
}
Are there any differences between these two implementations?