Finding the total number of processors on a machine with .NET
Andrew Lock describes how to find the total number of processors on a host or VM in modern .NET, which lacks a direct API, using P/Invoke on some platforms and file parsing on Linux. Environment.ProcessorCount returns host logical processors on .NET Framework, is partly container-aware on .NET Core before 6, and from .NET Core 6 returns processors available to the process when affinity or containers apply.
AI-written summary, checked against the cited sources. How summaries work
