C
C#2y ago
d0mkaaa

❔ My Label Doesn't show up even though no errors.

Hi, I am making like PC Stats app like HWInfo or something like that, but I am using Open Hardware Monitor libary but they say that they do have support for CPU Temps but I dont just get the CPU Temp Label to work. https://codeshare.io/ZJNE6e
29 Replies
d0mkaaa
d0mkaaaOP2y ago
In the gap thats where it should be.
friedice
friedice2y ago
seems like one of your if statements arent hitting
if (hardwareItem.HardwareType == HardwareType.CPU)
{
hardwareItem.Update();
foreach (var sensor in hardwareItem.Sensors)
{
if (sensor.SensorType == SensorType.Temperature)
{
lblCpuTemp.Text = "CPU Temperature: " + sensor.Value.ToString() + "°C";
}
}
}
if (hardwareItem.HardwareType == HardwareType.CPU)
{
hardwareItem.Update();
foreach (var sensor in hardwareItem.Sensors)
{
if (sensor.SensorType == SensorType.Temperature)
{
lblCpuTemp.Text = "CPU Temperature: " + sensor.Value.ToString() + "°C";
}
}
}
id put a breakpoint and debug
d0mkaaa
d0mkaaaOP2y ago
wait let me test nope @IceGPT still not showing up do you want me to give you the Form1.Designer.cs or
friedice
friedice2y ago
so both if statements are hitting and the cputemp.text is being applied?
d0mkaaa
d0mkaaaOP2y ago
yeah
friedice
friedice2y ago
could be an issue in databinding in the xaml maybe?
d0mkaaa
d0mkaaaOP2y ago
windows forms doesnt use xaml... or wpf
friedice
friedice2y ago
oh I have no idea about winforms
d0mkaaa
d0mkaaaOP2y ago
wait is there Qt for C# cause I might as use that for the GUI
Vi Ness
Vi Ness2y ago
Can you set the default text of lblCpuTemp and have it show up?
d0mkaaa
d0mkaaaOP2y ago
give me a sec wait I am still gonna try a Console.WriteLine to see if it writes to the console at least well I am not seeing anything in the Output imma go look at open hardware docs
friedice
friedice2y ago
So when you place a breakpoint on the line where lblCpuTemp.Text is assigned a value, does it display a value after the assignment statement is executed?
if (sensor.SensorType == SensorType.Temperature)
{
lblCpuTemp.Text = "CPU Temperature: " + sensor.Value.ToString() + "°C";
}
if (sensor.SensorType == SensorType.Temperature)
{
lblCpuTemp.Text = "CPU Temperature: " + sensor.Value.ToString() + "°C";
}
d0mkaaa
d0mkaaaOP2y ago
I dont think the whole entire code for the cpu temp even is getting ran
friedice
friedice2y ago
so your first if statement didnt hit then Hmm
d0mkaaa
d0mkaaaOP2y ago
oh it is wtf
d0mkaaa
d0mkaaaOP2y ago
the Console.WriteLine("cool") solved it
d0mkaaa
d0mkaaaOP2y ago
this must be a joke a console write line saved the day
d0mkaaa
d0mkaaaOP2y ago
d0mkaaa
d0mkaaaOP2y ago
I might need to try furmark and see if its perhaps getting the same info off my gpu ok yeah it is
friedice
friedice2y ago
your first if statement that checks for the cpu is going to be ignored btw
d0mkaaa
d0mkaaaOP2y ago
then thats the problem?
MODiX
MODiX2y ago
friedice
REPL Result: Success
if(false)
Console.WriteLine("This should not hit");
{
Console.WriteLine("this should not hit either");
}
if(false)
Console.WriteLine("This should not hit");
{
Console.WriteLine("this should not hit either");
}
Console Output
this should not hit either
this should not hit either
Compile: 497.504ms | Execution: 97.039ms | React with ❌ to remove this embed.
d0mkaaa
d0mkaaaOP2y ago
i might as just try to use a diff libary for the cpu temps
friedice
friedice2y ago
yes
friedice
friedice2y ago
an easier way to do this without having to console log would be to use breakpoints and debug
friedice
friedice2y ago
$debug
MODiX
MODiX2y ago
Tutorial: Debug C# code - Visual Studio (Windows)
Learn features of the Visual Studio debugger and how to start the debugger, step through code, and inspect data in a C# application.
d0mkaaa
d0mkaaaOP2y ago
man these fucking libraries are either fucking broken or they dont support my shit
Accord
Accord2y ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.

Did you find this page helpful?