Click here to Skip to main content
15,903,175 members
Please Sign up or sign in to vote.
3.67/5 (2 votes)
See more:
Okay.. So after a lot of struggling I managed to retrieve the CPU temperature with WMI.. My next problem however, is making the temperature Real-Time.. I have no idea where to even begin. Can someone point me in the right direction?

Thanks,
Chris
Posted
Comments
CPallini 30-Oct-12 13:43pm    
What do you mean exactly?
Christopher Smit 30-Oct-12 13:46pm    
Like I want the temperature to keep updating as the program runs. It shouldn't only retrieve it and then keep it as is.. It must keep reloading so to say so that the temperature keeps updating.

Hope you understand what I'm trying to say.
CPallini 30-Oct-12 13:49pm    
Then repeatedly ask WMI for it in a worker thread.
Christopher Smit 30-Oct-12 14:06pm    
Is that efficient?
CPallini 30-Oct-12 14:31pm    
I think it is feasible. You know temperature varies relatively slowly with time.

You can use OpenHardwareMonitor

http://code.google.com/p/open-hardware-monitor/[^]
http://openhardwaremonitor.org/support/[^]

upd.

C#
// We have a ListBox named lbList
        public void RefreshSensorData(){
            this.lbList.Items.Clear();
            OpenHardwareMonitor.Hardware.Computer computer = new OpenHardwareMonitor.Hardware.Computer();
            // enabling CPU to monitor
            computer.CPUEnabled = true;
            computer.Open();
            // enumerating all the hardware
            foreach (OpenHardwareMonitor.Hardware.IHardware hw in computer.Hardware){
                if (hw.HardwareType == OpenHardwareMonitor.Hardware.HardwareType.CPU){
                    hw.Update();
                    // searching for all sensors and adding data to listbox
                    foreach (OpenHardwareMonitor.Hardware.ISensor s in hw.Sensors){
                        if (s.SensorType != OpenHardwareMonitor.Hardware.SensorType.Temperature){
                            if (s.Value != null)
                                this.lbList.Items.Add(s.Value);
                        }
                    }
                }
            }
            computer.Close();
        }
 
Share this answer
 
v2
Comments
Christopher Smit 30-Oct-12 14:09pm    
How exactly do I use OpenHardwareMonitor with my application?
skydger 30-Oct-12 15:09pm    
Please see updated solution
You can build a service that starts up when the computer does. Here is a service sample: A Windows Service Application[^] or maybe use this article for a ping monitor: Ping Monitor[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900