Capturing Exceptions on async operations

前端 未结 6 1005
滥情空心
滥情空心 2021-01-12 01:00

I\'m reading up more about async here: http://msdn.microsoft.com/en-us/library/hh873173(v=vs.110).aspx

Going through this example:

Task [         


        
6条回答
  •  野趣味
    野趣味 (楼主)
    2021-01-12 01:48

    You're right. It is not necessary. You could replace it with

    if (recommendation.Result) 
        BuyStock(symbol);
    

    Also note that await will not await(will not set continuation) when completed task is given. It will just execute synchronously in that case as a optimization. I guess author leverages that optimization.

    If you ask why author wrote that way, May be consistency? only he knows!.

提交回复
热议问题