Why is the console window closing immediately once displayed my output?

前端 未结 21 2186
死守一世寂寞
死守一世寂寞 2020-11-22 03:45

I\'m studying C# by following the guides in MSDN.

Now, I just tried the Example 1 (here is the link to MSDN), and I\'ve encountered an i

21条回答
  •  有刺的猬
    2020-11-22 03:51

    this is the answer async at console app in C#?

    anything whereever in the console app never use await but instead use theAsyncMethod().GetAwaiter().GetResult();,

    example

    var result = await HttpClientInstance.SendAsync(message);

    becomes

    var result = HttpClientInstance.SendAsync(message).GetAwaiter().GetResult();

提交回复
热议问题