I have searched a lot of codes saying that is possible to use multiple cores with parallel async, but none worked. It is always stuck in a single core.
Is it possible?
Bellow it is a code that uses the recommend setting for running task run in multiples cores, but it is not happening.
class Program
{
static void Main(string[] args)
{
Task.Run(async () =>
{
var tasks = Enumerable.Range(0, 1000000)
.Select(i => Console.Out.WriteLineAsync((100000 * 10000).ToString()));
await Task.WhenAll(tasks);
}).GetAwaiter().GetResult();
}
}
Thanks for all the help.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…