C#任务是否在一个内核上运行? [英] Does a C# Task run on one core?
问题描述
C#任务是否在一个内核上运行?
Does a C# Task run on one core?
我有一个项目,需要确定要创建多少个任务. 我需要创建尽可能多的计算机. 那是处理器,核心或逻辑处理器的数量吗? 混淆了这三个选项.
I have a project where I need to decide how many Tasks to create. I need to create as many, as the computer can take. Is that the number of processors, cores, or logical processors, I am confused between the three options.
推荐答案
任务在线程上执行.操作系统将线程调度到内核.内核是一个逻辑概念,与物理CPU芯片不同.
A task executes on a thread. The OS schedules threads to cores. Cores are a logical concept and different from physical CPU chips.
创建Environment.ProcessorCount
任务,或者更好地使用PLINQ或Parallel
之类的更高级别的TPL构造之一.
Create Environment.ProcessorCount
tasks, or better use one of the higher level TPL constructs like PLINQ or Parallel
.
这篇关于C#任务是否在一个内核上运行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!