I am working on a small app that would track certain GPU parameters. I am currently using 5 background workers for 5 different parameters that are being tracked, the operations run until my app is closed. I know this is probably not a good way to do it. What would be a good way to monitor these parameters in the background without having to create a worker for each parameter?
Edit: Reverted back to the original question that I asked now that the question was reopened.
Test file that monitors the temperature only.
using NvAPIWrapper.GPU;
using System.ComponentModel;
using System.Threading;
using System.Windows.Forms;
namespace TestForm
{
public partial class Form1 : Form
{
private PhysicalGPU[] gpus = PhysicalGPU.GetPhysicalGPUs();
public Form1()
{
InitializeComponent();
GPUTemperature();
}
private void GPUTemperature()
{
backgroundWorker1.RunWorkerAsync();
}
private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
{
while (!backgroundWorker1.CancellationPending)
{
foreach (var gpu in gpus)
{
foreach (var sensor in gpu.ThermalInformation.ThermalSensors)
{
backgroundWorker1.ReportProgress(sensor.CurrentTemperature);
Thread.Sleep(500);
}
}
}
}
private void backgroundWorker1_ProgressChanged(object sender,
ProgressChangedEventArgs e)
{
temperature.Text = e.ProgressPercentage.ToString();
}
}
}