mirror of
https://github.com/jkocon/g-helper.git
synced 2026-02-23 13:00:52 +01:00
Performance tweaks
This commit is contained in:
@@ -174,22 +174,12 @@ public static class HardwareControl
|
||||
|
||||
public static float? GetCPUTemp() {
|
||||
|
||||
if (Math.Abs(DateTimeOffset.Now.ToUnixTimeMilliseconds() - lastUpdate) < 1000) return cpuTemp;
|
||||
lastUpdate = DateTimeOffset.Now.ToUnixTimeMilliseconds();
|
||||
var last = DateTimeOffset.Now.ToUnixTimeSeconds();
|
||||
if (Math.Abs(last - lastUpdate) < 2) return cpuTemp;
|
||||
lastUpdate = last;
|
||||
|
||||
cpuTemp = Program.acpi.DeviceGet(AsusACPI.Temp_CPU);
|
||||
|
||||
if (cpuTemp < 0) try
|
||||
{
|
||||
using (var ct = new PerformanceCounter("Thermal Zone Information", "Temperature", @"\_TZ.THRM", true))
|
||||
{
|
||||
cpuTemp = ct.NextValue() - 273;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Debug.WriteLine("Failed reading CPU temp :" + ex.Message);
|
||||
}
|
||||
//Debug.WriteLine(cpuTemp);
|
||||
|
||||
return cpuTemp;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user