0

I'm new to Web APIs. I have a basic question.

If I don't add await in front of the SendAsync() method in .NET, will it in that case be a synchronous call?

Ivar
  • 6,138
  • 12
  • 49
  • 61
kran
  • 21
  • 2
  • 1
    Be clear - `await` doesn't *start* anything. `SendAsync` is invoked and has *no idea* what the caller is going to do with its result when it chooses to return, including whether or not it directly or indirectly ends up using it with `await`. – Damien_The_Unbeliever Jul 07 '21 at 10:29
  • 2
    No, why would it? – derpirscher Jul 07 '21 at 10:30
  • @Damien_The_Unbeliever OK! But I´m trying to understand what is async in such case? If I inovke SendAsync() and not giving the control back to calling method... – kran Jul 07 '21 at 11:38
  • @kran - `await` is literally "async wait" - it waits for *something* (and it doesn't care what) and it does so whilst not blocking the current thread. A common mistake I see (and suspect you had) is people thinking that it *starts* something running, creates a thread, etc, when it's almost the opposite. – Damien_The_Unbeliever Jul 07 '21 at 12:10

0 Answers0