Capturing Exceptions on async operations

前端 未结 6 1015
滥情空心
滥情空心 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:24

    If I already did this: Task recommendation = await Task.WhenAny(recommendations); Why do this: if (await recommendation) BuyStock(symbol);

    Because Task.WhenAny returns a Task> and you want to unwrap the outter Task to retrieve the resulting bool. You could do the same by accessing the Task.Result property of the returned Task

提交回复
热议问题