based on what I have read on 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. You can use Task.Run to move CPU-bound work to a background thread, but a background thread doesn't help with a process that's just waiting for results to become available.
It is basically saying no thread will be created. But inside a class which I inherited HttpClient
I found something interesting..
async Task<T> SendAsync<T>(HttpMethod method, Uri uri, HttpContent content, CancellationToken cancellationToken)
{
HttpRequestMessage msg = new HttpRequestMessage(method, uri);
msg.Content = content;
//On Main Thread
HttpResponseMessage response = await SendAsync(msg, cancellationToken);
//On worker thread
//...
}
the method is called inside static void Main
Task result = client.GetAsync<string>(...);
//GetAsync calls await SendAsync<T>
result.Wait();
Why am I on a separate thread after await SendAsnc
call?? I thought asyn creats no new thread. Or at least it will be invoked back to the original thread after await.