await
instead of Task.ContinueWith
Task.ContinueWith
has some surprising and non-intuitive behaviors, so must be used with care.await
has none of these problems. It is also more readable.Task.ContinueWith
should not be used unless you are doing dynamic task parallelism, which is rare.await downloadTask.ContinueWith(async t => await SaveFileAsync(t.Result));
await SaveFileAsync(await downloadTask);