今のところ、一度温度を表示しています。openhardwaremonitorの元のプログラムのように、毎秒温度が変化/更新されるように、または温度に変化があるかどうかに応じて、そこでどのように機能するかわからないように機能させたいです。
私がしたことは、コンストラクターからすべてのforeachループを取り出し、それをタイマーティックイベントに入れることです。しかし、それはうまくいきません。openhardwaremonitorでは、表示が51cに変更されましたが、私のアプリケーションでは、アプリケーションを初めて実行したときと同じように、常に44cで表示されていました。
textBox行にブレークポイントを使用し、そこに到達することで内部ループを実行することもありますが、dosentはifとdosentがメッセージボックスに到達し、メッセージボックスに到達する場合は44cを表示します。
コード:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Management;
using OpenHardwareMonitor.Hardware;
namespace NvidiaTemp
{
public partial class Form1 : Form
{
Computer computer = new Computer();
public Form1()
{
InitializeComponent();
computer.Open();
computer.GPUEnabled = true;
timer1.Enabled = true;
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void timer1_Tick(object sender, EventArgs e)
{
foreach (var hardwareItem in computer.Hardware)
{
if (hardwareItem.HardwareType == HardwareType.GpuNvidia)
{
foreach (var sensor in hardwareItem.Sensors)
{
if (sensor.SensorType == SensorType.Temperature)
{
// MessageBox.Show(String.Format("The current temperature is {0}", sensor.Value));
textBox1.Text = String.Format("The current temperature is {0}", sensor.Value);
}
}
}
}
}
}
}
ループを実行するたびにtextBox行に到達するように更新しないのはなぜですか?
openhardwaremonitorの元のプログラムで温度値に変更があったり、タイマーで動作したりした場合、温度を更新しますか?