Understanding async and await

后端 未结 1 1413
终归单人心
终归单人心 2021-01-14 20:02

I am trying to learn the details of MVC5 and I came across something that baffles me. In the accountController that comes by default with an MVC5 project with Individual Au

相关标签:
1条回答
  • 2021-01-14 20:58

    The difference between SomeMethod() and await SomeMethodAsync() is that the latter won't block a thread while the method performs IO. Because of that, the application becomes more scalable, because it can use smaller number of threads to serve the same number of requests.

    If you don't care about scalability, then it doesn't matter much which of the two options are you going to choose. But it's probably still better to use the async version, to future-proof your application, so that your application behaves well when scalability becomes an issue.

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