The first is something important: runtime will only return to the caller on await if the expected task is not completed yet.
Question 1: I will provide the MSDN here:
Asynchronous and pending keywords do not create additional threads. Asynchronous methods do not require multithreading because the async method does not start in its thread.
A source
Question 2: It is possible in the implementation of GetStringAsync , but we do not know this, and we also do not need to know this. All we need to know is that GetStringAsync somehow gets its result without blocking our thread.
Question 3: If the loop is placed before the await keyword, yes.
Question 4: Quote from the same paragraph as before:
You can use Task.Run to move processor related work to the background thread
You do not need the async and await keywords for this. Example:
private Task<int> DoSomethingAsync() { return Task.Run(() => {
Question 5: I will cite again
An asynchronous method usually contains one or more occurrences of the wait statement, but the absence of pending expressions does not cause a compiler error. If the asynchronous method does not use the wait operator to mark the suspension point, the method runs as a synchronous method, despite the async modifier. The compiler generates a warning for such methods.
Source (on the same page as before, only in a different section)
source share