0

best practise is using async actions in API. OK:

    [HttpGet]
    public async Task<ActionResult<string>> Get()
    {
        await Task.Delay(10000);
        return "END";
    }

I call this code multiple. There are responses time: 1. 10s
2. 20s
3. 30s
.... responses are not async but sync? Why?

Why aren't all the responses in 10 seconds when it's async?

motorcb
  • 1,043
  • 3
  • 10
  • 19
  • Why is that @Alexan? – Igor May 12 '20 at 19:49
  • How are you invoking it? What were you expecting? – Paulo Morgado May 12 '20 at 20:40
  • is it possible that when you invoke the requests, you are iteratively invoking them in a non-parralel fashion? I.e. in pseudo code: for(x=0;x<3;x++) { call get(); } such an approach would guarantee you do not take advantage of the non-blocking state of async/await, since you must wait for the completion of the request in order to start the next one on the CLIENT. – apinostomberry Apr 25 '23 at 20:30

0 Answers0