Using async without await

后端 未结 1 1657
我寻月下人不归
我寻月下人不归 2020-11-28 13:02

I\'d like to make a function async, so I simply add async like this:

public async static void something(){
}

You can see that

相关标签:
1条回答
  • 2020-11-28 13:52

    I think that maybe you misunderstand what async does. The warning is exactly right: if you mark your method async but don't use await anywhere, then your method won't be asynchronous. If you call it, all the code inside the method will execute synchronously.

    Also, you should try to avoid using async void methods, they make handling exceptions difficult.

    0 讨论(0)
提交回复
热议问题