Let's consider this code :
var tasks = actionItems.Select(t => DoSmthAsync());
var resultAll = await Task.WhenAll(tasks);
And method:
public async Task<int> DoSmthAsync()
{
Debug.WriteLine("Threadid=" + Thread.CurrentThread.ManagedThreadId);
var result = await DoSmthAnotherAsync();
Debug.WriteLine("ThreadId=" + Thread.CurrentThread.ManagedThreadId);
return result;
}
I expect that this will be executed parallel in different threads, but I see that it work in the same thread. Also, I don't understand when a task run?