PDA

View Full Version : نمایش cpu Using , Memory



MehdiLiver
دوشنبه 03 اسفند 1388, 00:03 صبح
سلام
چطور میشه در فرم Cpu Using رو در یک Label
و Memory رو در یک Label دیگه نمایش داد ؟؟؟

r00tkit
دوشنبه 03 اسفند 1388, 00:37 صبح
using System.Diagnostics;
PerformanceCounter cpuCounter;
PerformanceCounter ramCounter;

cpuCounter = new PerformanceCounter();

cpuCounter.CategoryName = "Processor";
cpuCounter.CounterName = "% Processor Time";
cpuCounter.InstanceName = "_Total";

ramCounter = new PerformanceCounter("Memory", "Available MBytes");


public string getCurrentCpuUsage(){
cpuCounter.NextValue()+"%";
}

public string getAvailableRAM(){
ramCounter.NextValue()+"MB";
}


حالا مقدار هار رو تو لیبل قرار بده با


label1.Text=getCurrentCpuUsage();
:چشمک:

از timer استفاده کن تا برنامت dynamic بشه