C# provides two ways of creating asynchronous methods:
Task()
:
static Task<string> MyAsyncTPL() {
Task<string> result = PerformWork();
return result.ContinueWith(t => MyContinuation());
}
async Task()
:
static async Task<string> MyAsync() {
string result = await PerformWork();
return MyContinuation();
}
Both of the above methods are async
and achieve the same thing. So, when should I choose one method over the other? Are there any guidelines or advantages of using one over the other?