PDA

View Full Version : خیل مهم:به دست آوردن زمان استفاده ازcpu



me_elsagh
پنج شنبه 26 آذر 1388, 12:02 عصر
به دست آوردن میزان استفاده ازcpuیکprocessبه چه صورت است؟

HollyGhost
پنج شنبه 26 آذر 1388, 12:33 عصر
اولین نتیجه از گوگل:
http://stackoverflow.com/questions/278071/how-to-get-the-cpu-usage-c

تعریفات در کلاس


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";
}