Click here to Skip to main content
15,887,175 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi guys i have 3labels Ping,CPU,Memory and i want to display my cpu usage inside it , memory usage and ping all labels must get updated every 1 minute

Can anyone help?

Im not sure how.
Posted
Updated 5-Apr-14 9:54am
v3
Comments
Homero Rivera 5-Apr-14 16:36pm    
What do you mean by Ping ? The other 2 I got them.

1 solution

CPU and mem are just WMI and PerformanceCounter objects:
C#
            // CPU
            ManagementObjectSearcher cpuSearch = new ManagementObjectSearcher(@"\root\CIMV2",
                      "SELECT * FROM Win32_PerfFormattedData_PerfOS_Processor WHERE Name=\"_Total\"");
            ManagementObjectCollection moc = cpuSearch.Get();
            ManagementObject mo = moc.Cast<managementobject>().First();
            string cpu = mo["PercentIdleTime"].ToString();
            // MEM
            PerformanceCounter memCounter = new PerformanceCounter("Memory", "Available MBytes");
            string mem = memCounter.NextValue().ToString();
</managementobject>

Ping is not something you can just measure: it's a round trip time value to a specific server, and it measures the connection speed of both machines and their response times. You can't just say "My ping is nn" because it is completely meaningless! It needs a server to measure it against.
 
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