Async Method skips await

前端 未结 2 1593
庸人自扰
庸人自扰 2021-01-27 09:27

I have the following code:

public async Task GetData(Uri source)
{
    if (client.IsBusy == true) 
        client.CancelAsync ();

    Task

        
2条回答
  •  刺人心
    刺人心 (楼主)
    2021-01-27 09:43

    An async method returns as soon as an await statement is reached, if the thing awaited hasn't finished. Once it completes, the method continues execution after that await statement. Try putting a break point on the return statement and it should get hit twice.

提交回复
热议问题