Reputation: 71
newbie question here!
Originally, we had the following below setup, in which case I used the WebClient.DownloadStringTaskAsync with async task. My reasoning was because I was making DB calls.
webpage --> Web API Controller --> DB
We've added another layer for security reasons and now web page makes a ajax request to Web Api Controller which in turn makes a Web Api Controller to a Perl REST Service.
webpage --> Web API Controller --> Perl REST Service --> DB
Since the Web API Controller is not accessing the DB directly, am I okay not to use async task?
I guess my question is when should I use async tasks ?
Thanks!!
Upvotes: 0
Views: 114
Reputation: 16440
If your Web API controller action isn't async
, the thread used for this HTTP request can't be given back to the thread pool while you're waiting for the Perl REST service (and the database) to respond. Therefore, it's blocked and can't be used to process other HTTP requests to your API.
Upvotes: 2