Skip to content
  • English Deutsch

benjamin-abt.com

Performance is a feature | Cloud - AI - Azure - .NET - Sustainability

  • Home
  • Blog
  • Portfolio
    • Overview
    • Workshops & Training
    • Publications
  • Contact
  • Home
  • Blog

Read System Properties like CPU Temperatures with .NET Core

Read System Properties like CPU Temperatures with .NET Core
October 9, 2019 4 min read BEN ABT
.NET

This article was written in 2019. Versions, tools and recommendations may have changed since then. Newer posts are collected under .NET.

Through a forum post I discovered the NuGet package OpenHardwareMonitorLibCore and wanted to test it.

Apparently this is a wrapper of a very popular tool (https://openhardwaremonitor.org/) , with whose help you can read out all kinds of system properties. This includes the CPU and its sensors.

So I took a look at the library and built a short sample:

C#
  1using System;
  2using System.Collections.Generic;
  3using System.Linq;
  4using System.Threading.Tasks;
  5using OpenHardwareMonitor.Hardware;
  6
  7namespace ConsoleApp
  8{
  9    class Program
 10    {
 11        static async Task Main(string[] args)
 12        {
 13            Console.WriteLine("Read system information..." + Environment.NewLine);
 14            Console.WriteLine("Results:");
 15            SystemInfo systemInfo = await ReadSystemInfoAsync();
 16
 17            foreach (SystemInfo.CoreInfo cInfo in systemInfo.CoreInfos)
 18            {
 19                Console.WriteLine($"Name: {cInfo.Name} - {cInfo.Load} % - {cInfo.Temp} °C");
 20            }
 21
 22            Console.WriteLine("Done.");
 23            Console.ReadKey();
 24        }
 25
 26        public static async Task<SystemInfo> ReadSystemInfoAsync()
 27        {
 28            return await Task.Run(() =>
 29            {
 30                SystemInfo systemInfo = new SystemInfo();
 31
 32                SystemVisitor updateVisitor = new SystemVisitor();
 33                Computer computer = new Computer();
 34
 35                try
 36                {
 37                    computer.Open();
 38                    computer.CPUEnabled = true;
 39
 40                    computer.Accept(updateVisitor);
 41
 42                    foreach (IHardware hw in computer.Hardware
 43                        .Where(hw => hw.HardwareType == HardwareType.CPU))
 44                    {
 45                        foreach (ISensor sensor in hw.Sensors)
 46                        {
 47                            switch (sensor.SensorType)
 48                            {
 49                                case SensorType.Load:
 50                                    systemInfo.AddOrUpdateCoreLoad(
 51                                    sensor.Name, sensor.Value.GetValueOrDefault(0));
 52
 53                                    break;
 54                                case SensorType.Temperature:
 55                                    systemInfo.AddOrUpdateCoreTemp(
 56                                    sensor.Name, sensor.Value.GetValueOrDefault(0));
 57
 58                                    break;
 59                            }
 60                        }
 61                    }
 62                }
 63                finally
 64                {
 65                    computer.Close();
 66                }
 67
 68                return systemInfo;
 69            });
 70        }
 71    }
 72
 73    public class SystemInfo
 74    {
 75        public class CoreInfo
 76        {
 77            public string Name { get; set; }
 78            public double Load { get; set; }
 79            public double Temp { get; set; }
 80        }
 81
 82        public List<CoreInfo> CoreInfos = new List<CoreInfo>();
 83
 84        private CoreInfo GetCoreInfo(string name)
 85        {
 86            CoreInfo coreInfo = CoreInfos.SingleOrDefault(c => c.Name == name);
 87            if (coreInfo is null)
 88            {
 89                coreInfo = new CoreInfo { Name = name };
 90                CoreInfos.Add(coreInfo);
 91            }
 92
 93            return coreInfo;
 94        }
 95
 96        public void AddOrUpdateCoreTemp(string name, double temp)
 97        {
 98            CoreInfo coreInfo = GetCoreInfo(name);
 99            coreInfo.Temp = temp;
100        }
101
102        public void AddOrUpdateCoreLoad(string name, double load)
103        {
104            CoreInfo coreInfo = GetCoreInfo(name);
105            coreInfo.Load = load;
106        }
107    }
108
109    public class SystemVisitor : IVisitor
110    {
111        public void VisitComputer(IComputer computer) { computer.Traverse(this); }
112
113        public void VisitHardware(IHardware hardware)
114        {
115            hardware.Update();
116            foreach (IHardware subHardware in hardware.SubHardware) subHardware.Accept(this);
117        }
118
119        public void VisitSensor(ISensor sensor) { }
120        public void VisitParameter(IParameter parameter) { }
121    }
122}

This snippet reads all my cores as well as their name, load and temperature.

Shell
 1    Read system information...
 2
 3    Results:
 4    Name: CPU Core #1 - 50 % - 0 °C
 5    Name: CPU Core #2 - 0 % - 0 °C
 6    Name: CPU Core #3 - 0 % - 0 °C
 7    Name: CPU Core #4 - 0 % - 0 °C
 8    Name: CPU Core #5 - 0 % - 0 °C
 9    Name: CPU Core #6 - 0 % - 0 °C
10    Name: CPU Core #7 - 0 % - 0 °C
11    Name: CPU Core #8 - 0 % - 0 °C
12    Name: CPU Core #9 - 0 % - 0 °C
13    Name: CPU Core #10 - 0 % - 0 °C
14    Name: CPU Core #12 - 0 % - 0 °C
15    Name: CPU Total - 4,17 % - 0 °C
16    Name: CPU Package - 0 % - 0 °C
17Done.

Unfortunately you can already see that the temperature of the cores is not read out. I couldn’t find out why.

Blocking Code

The NuGet package / lib does not offer any asynchronous methods, which means that the system properties have to be read within a Task or Thread. Otherwise, the UI of a Windows Forms or WPF application hangs. In the worst case Windows closes your application.

NET Core and .NET Framework

Unlike the .NET Framework, .NET Core itself does not provide any functionality to read such system information. The library is also not cross-platform capable and works with a .NET Core 3.0 console application only on Windows.

Related articles

Containerizing .NET in 2026 Without a Dockerfile

Oct 20, 2026 - 11 min read

Containerizing .NET in 2026 Without a Dockerfile

Most .NET Dockerfiles repeat the same five steps: restore, publish, select the matching Microsoft runtime image, copy the output and start …

Problem Details in ASP.NET Core and .NET 11

Oct 5, 2026 - 12 min read

Problem Details in ASP.NET Core and .NET 11

builder.Services.AddProblemDetails() registers infrastructure. It does not create an error contract. An ASP.NET Core request can fail during …

Resilience in .NET with Microsoft.Extensions.Resilience

Sep 21, 2026 - 11 min read

Resilience in .NET with Microsoft.Extensions.Resilience

Retries are the most visible resilience strategy and the easiest one to misuse. Repeating a failing call can recover from a short network …


BEN ABT

BEN ABT

Ben is Chief Engineering Officer and Principal Software Engineer at Medialesson.de, with a strong focus on .NET and Microsoft Azure. In his professional role, he designs and builds highly scalable platforms for hybrid and cloud-based scenarios. He also advises companies and C-levels on migrating to the sovereign cloud.

He runs myCSharp.de, the largest and most active German-speaking C# community forum, actively contributes to both his own and external open-source projects and regularly shares his knowledge through his blog, at community events, conferences and as a writer for technical magazines.

Let's Work Together

Looking for an experienced Platform Architect or Engineer for your next project? Whether it's cloud migration, platform modernization or building new solutions from scratch - I'm here to help you succeed.

New Platforms

Modernization

Training & Consulting

Contact Me
X Facebook LinkedIn WhatsApp
Back Next Blog Post

Open for work!

Contact Me
BEN ABT BEN ABT Software Engineer · Microsoft MVP Passionate about .NET, Azure, performance optimization and sustainable software engineering.

Medialesson GmbH Logo

Microsoft MVP Logo

Recent posts

View all
Stop Using nginx as Your Default Static File Server in Docker

Stop Using nginx as Your Default Static File Server in …

Oct 24, 2026
Containerizing .NET in 2026 Without a Dockerfile

Containerizing .NET in 2026 Without a Dockerfile

Oct 20, 2026
Problem Details in ASP.NET Core and .NET 11

Problem Details in ASP.NET Core and .NET 11

Oct 5, 2026
Resilience in .NET with Microsoft.Extensions.Resilience

Resilience in .NET with Microsoft.Extensions.Resilience

Sep 21, 2026
What Matters in ASP.NET Core 11

What Matters in ASP.NET Core 11

Sep 14, 2026

Tags

.NET (192) Csharp (96) ASP.NET Core (48) Azure (41) DevOps (17) Docker (14) Microsoft (14) EF Core (11) Microsoft MVP (11) AI (10) GitHub (10) GitHub Copilot (10) ASP.NET (9) Security (9) Synology (9) Architecture (8) Raspberry (8) Azure Functions (7) Cloudflare (7) Bicep (6)
benjamin-abt.com

About BEN

Benjamin Abt is a Software Engineer, Platform Architect and Microsoft MVP specializing in .NET, Azure, cloud architecture, performance optimization and sustainable software development.

Connect

  • Follow me on GitHub
  • Follow me on LinkedIn
  • Follow me on Mastodon
  • Microsoft MVP profile
  • Follow SchwabenCode on GitHub
  • Follow me on X

Quick Links

  • Portfolio
  • Blog
  • Workshops & Training
  • Publications
  • Get in Touch
  • Sitemap
Open for Work

© Copyright Benjamin Abt & SchwabenCode | 2011 - 2026

Content licensed under CC BY 4.0 unless otherwise noted.

  • Impressum
  • Privacy
  • Contact