C
C#17mo 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
d0mkaaaOP17mo ago
In the gap thats where it should be.
friedice
friedice17mo 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
d0mkaaaOP17mo ago
wait let me test nope @IceGPT still not showing up do you want me to give you the Form1.Designer.cs or
friedice
friedice17mo ago
so both if statements are hitting and the cputemp.text is being applied?
d0mkaaa
d0mkaaaOP17mo ago
yeah
friedice
friedice17mo ago
could be an issue in databinding in the xaml maybe?
d0mkaaa
d0mkaaaOP17mo ago
windows forms doesnt use xaml... or wpf
friedice
friedice17mo ago
oh I have no idea about winforms
d0mkaaa
d0mkaaaOP17mo ago
wait is there Qt for C# cause I might as use that for the GUI
Vi Ness
Vi Ness17mo ago
Can you set the default text of lblCpuTemp and have it show up?
d0mkaaa
d0mkaaaOP17mo 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
friedice17mo 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
d0mkaaaOP17mo ago
I dont think the whole entire code for the cpu temp even is getting ran
friedice
friedice17mo ago
so your first if statement didnt hit then Hmm
d0mkaaa
d0mkaaaOP17mo ago
oh it is wtf
d0mkaaa
d0mkaaaOP17mo ago
the Console.WriteLine("cool") solved it
d0mkaaa
d0mkaaaOP17mo ago
this must be a joke a console write line saved the day
d0mkaaa
d0mkaaaOP17mo ago
d0mkaaa
d0mkaaaOP17mo ago
I might need to try furmark and see if its perhaps getting the same info off my gpu ok yeah it is
friedice
friedice17mo ago
your first if statement that checks for the cpu is going to be ignored btw
d0mkaaa
d0mkaaaOP17mo ago
then thats the problem?
MODiX
MODiX17mo 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
d0mkaaaOP17mo ago
i might as just try to use a diff libary for the cpu temps
friedice
friedice17mo ago
yes
friedice
friedice17mo ago
an easier way to do this without having to console log would be to use breakpoints and debug
friedice
friedice17mo ago
$debug
MODiX
MODiX17mo 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
d0mkaaaOP17mo ago
man these fucking libraries are either fucking broken or they dont support my shit
Accord
Accord17mo 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.
Want results from more Discord servers?
Add your server