我知道你可以得到一個單獨的進程,因爲我有以下的總CPU使用率,但我想知道是否有可能得到每個單獨的表單的CPU使用率應用。C#CPU使用率單獨(子)winforms
using (PerformanceCounter pCounter = new PerformanceCounter("Process", "% Processor Time", Process.GetCurrentProcess().ProcessName))
{
pCounter.NextValue();
System.Threading.Thread.Sleep(1000);
Console.WriteLine("Process: {0}, CPU: {1}%", Process.GetCurrentProcess().ProcessName, pCounter.NextValue());
}
是否可以使用像上面的代碼的東西以獲取應用程序中的各個表單CPU使用率,或者這是簡單的不可能的 - 或者太多的工作成果?
爲了什麼目的?一般性能調整,或者你正在尋找一個錯誤? – Kye
@Kye我正在做一個自定義shell,並想知道如果我可以通過這種方式獲取我的表單的CPU使用情況,但似乎不是這樣,我將不得不重新考慮我的代碼。 – 73cn0109y