I am confused with asyn and await apporach, as per MSDN
"The async and await keywords don't cause additional threads to be created. Async methods don't require multithreading because an async method doesn't run on its own thread. The method runs on the current synchronization context and uses time on the thread only when the method is active."
If the async method is not using any threads from threadpool, main thread is busy executing the non-async code, how/where does the async code gets executed?
Example : In the below example how does the longRunningTask gets executes if not on thread from thread pool?
public async Task MyMethod()
{
Task<int> longRunningTask = LongRunningOperation();
//indeed you can do independent to the int result work here
//and now we call await on the task
int result = await longRunningTask;
//use the result
Console.WriteLine(result);
}
public async Task<int> LongRunningOperation() // assume we return an int
{
await Task.Delay(1000); //1 seconds delay
return 1;
}