Search
 
SCRIPT & CODE EXAMPLE
 

CSHARP

how to use open hardware monitor in c#

<p>using System;<br>using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using OpenHardwareMonitor.Hardware;
namespace Get_CPU_Temp5
{
   class Program
   {
       public class UpdateVisitor : IVisitor
       {
           public void VisitComputer(IComputer computer)
           {
               computer.Traverse(this);
           }
           public void VisitHardware(IHardware hardware)
           {
               hardware.Update();
               foreach (IHardware subHardware in hardware.SubHardware) subHardware.Accept(this);
           }
           public void VisitSensor(ISensor sensor) { }
           public void VisitParameter(IParameter parameter) { }
       }
       static void GetSystemInfo()
       {
           UpdateVisitor updateVisitor = new UpdateVisitor();
           Computer computer = new Computer();
           computer.Open();
           computer.CPUEnabled = true;
           computer.Accept(updateVisitor);
           for (int i = 0; i < computer.Hardware.Length; i++)
           {
               if (computer.Hardware[i].HardwareType == HardwareType.CPU)
               {
                   for (int j = 0; j < computer.Hardware[i].Sensors.Length; j++)
                   {
                       if (computer.Hardware[i].Sensors[j].SensorType == SensorType.Temperature)
                               Console.WriteLine(computer.Hardware[i].Sensors[j].Name + ":" + computer.Hardware[i].Sensors[j].Value.ToString() + "
");
                   }
               }
           }
           computer.Close();
       }
       static void Main(string[] args)
       {
           while (true)
           {
               GetSystemInfo();
           }
       }
   }
}
Comment

PREVIOUS NEXT
Code Example
Csharp :: how to set the current user httpcontext.current.user asp.net -mvc 
Csharp :: Test for even Number 
Csharp :: cread 2-dimensional array in c# 
Csharp :: tilemap shader 
Csharp :: .net core copy file in folder to root 
Csharp :: use c#9 
Csharp :: HtmlToPdfConverter 
Csharp :: modal barrier in flutter 
Csharp :: display none asp.net 
Csharp :: datagridview column index 
Csharp :: array sum c# 
Csharp :: asp.net core update-database specify environment 
Csharp :: unity how to check index of enum 
Csharp :: c# switch when 
Csharp :: c# new object 
Csharp :: c# catch two exceptions in one block 
Csharp :: c# multiple exceptions same handler 
Csharp :: list view in unity 
Csharp :: linq syntax 
Csharp :: out c# 
Csharp :: assert.equal 
Csharp :: string vs string c# 
Csharp :: VBNet dictionary for each 
Csharp :: asp.net store list in web.config 
Csharp :: c# yes no cancel dialog with icons 
Csharp :: c# fold sum array 
Csharp :: Photon Register Callbacks 
Csharp :: entity framework linq join 2 tables c# 
Csharp :: c# ushort 
Csharp :: mono cast 
ADD CONTENT
Topic
Content
Source link
Name
6+1 =