In the context of a console application using async / await constructors , I would like to know if it is possible to execute "continuations" on multiple threads on different CPUs in parallel.
I think this is the case, since continuations are published in the default task scheduler (there is no SynchronizationContext application in the console application), which is a thread pool.
I know that the async / await construct does not create any additional thread. However, for a thread pool there must be at least one thread configured for each processor, and therefore, if continuations are sent in the thread pool, it can schedule tasks to continue in parrallel on different CPUs ... this is what I thought, but for some reason I was very confused yesterday, and I am no longer sure.
Here is a simple code:
public class AsyncTest
{
int i;
public async Task DoOpAsync()
{
await SomeOperationAsync();
i++;
}
public void Start()
{
for (int i=0; i<1000; i++)
{ var _ = DoOpAsync(); }
}
}
SomeOperationAsync does not create a single thread on its own, and let, for example, say that it simply sends some request asynchronously, relying on the I / O completion port, so as not to block a draw at all.
, , 1000 , , ( ) ? i.e "i"?