public static void ThreadLoop() { while (!_shouldStop) { pSDK.RefreshInformation(); Thread.Sleep(1000); } }
public static void ThreadLoop() { //while ((Thread.CurrentThread.IsAlive) && (!_shouldStop)) while (!_shouldStop) { pSDK.RefreshInformation(); Thread.Sleep(1000); } }
public void update_sensors(Dictionary <string, dynamic> devices, Dictionary <string, dynamic> sensors) { int NbDevices; int device_index; string devicename; int deviceclass; var mb = new MB_sensors(); var cpus = new List <CPU_sensors>(); var hdds = new List <HDD_sensors>(); var gpus = new List <GPU_sensors>(); pSDK.RefreshInformation(); NbDevices = pSDK.GetNumberOfDevices(); for (device_index = 0; device_index < NbDevices; device_index += 1) { devicename = pSDK.GetDeviceName(device_index); deviceclass = pSDK.GetDeviceClass(device_index); if (deviceclass == CPUIDSDK.CLASS_DEVICE_MAINBOARD) { mb.name = devicename; mb.fans = get_sensor_list(device_index, CPUIDSDK.SENSOR_CLASS_FAN); mb.temps = get_sensor_list(device_index, CPUIDSDK.SENSOR_CLASS_TEMPERATURE); mb.volts = get_sensor_list(device_index, CPUIDSDK.SENSOR_CLASS_VOLTAGE); } else if (deviceclass == CPUIDSDK.CLASS_DEVICE_PROCESSOR) { var cpu = new CPU_sensors(); cpu.name = devicename; cpu.loads = get_sensor_list(device_index, CPUIDSDK.SENSOR_CLASS_UTILIZATION); cpu.temps = get_sensor_list(device_index, CPUIDSDK.SENSOR_CLASS_TEMPERATURE); cpu.volts = get_sensor_list(device_index, CPUIDSDK.SENSOR_CLASS_VOLTAGE); cpu.clocks = get_sensor_list(device_index, CPUIDSDK.SENSOR_CLASS_CLOCK_SPEED); cpu.watts = get_sensor_list(device_index, CPUIDSDK.SENSOR_CLASS_POWER); cpus.Add(cpu); } else if (deviceclass == CPUIDSDK.CLASS_DEVICE_DRIVE) { var hdd = new HDD_sensors(); hdd.name = devicename.Trim(); hdd.loads = get_sensor_list(device_index, CPUIDSDK.SENSOR_CLASS_UTILIZATION); foreach (var x in hdd.loads) { x.name = get_drive_letter(x.name); } hdd.temps = get_sensor_list(device_index, CPUIDSDK.SENSOR_CLASS_TEMPERATURE); hdds.Add(hdd); } else if (deviceclass == CPUIDSDK.CLASS_DEVICE_DISPLAY_ADAPTER) { var gpu = new GPU_sensors(); gpu.name = devicename; gpu.fans = get_sensor_list(device_index, CPUIDSDK.SENSOR_CLASS_FAN); gpu.loads = get_sensor_list(device_index, CPUIDSDK.SENSOR_CLASS_UTILIZATION); gpu.temps = get_sensor_list(device_index, CPUIDSDK.SENSOR_CLASS_TEMPERATURE); gpus.Add(gpu); } } sensors["mb"] = mb; sensors["cpus"] = cpus; sensors["hdds"] = hdds; sensors["gpus"] = gpus; sensors["memory"] = get_memory_usage(); if (devices["memory"].spd.Count > 0) { sensors["memory"].name = devices["memory"].spd[0].name; } }