<pre id="bbfd9"><del id="bbfd9"><dfn id="bbfd9"></dfn></del></pre>

          <ruby id="bbfd9"></ruby><p id="bbfd9"><mark id="bbfd9"></mark></p>

          <p id="bbfd9"></p>

          <p id="bbfd9"><cite id="bbfd9"></cite></p>

            <th id="bbfd9"><form id="bbfd9"><dl id="bbfd9"></dl></form></th>

            <p id="bbfd9"><cite id="bbfd9"></cite></p><p id="bbfd9"></p>
            <p id="bbfd9"><cite id="bbfd9"><progress id="bbfd9"></progress></cite></p>
            計算機硬件

            利用C#監控計算機CPU的使用率

            時間:2025-03-31 21:28:30 計算機硬件 我要投稿
            • 相關推薦

            利用C#監控計算機CPU的使用率

              今天在網上看到一段比較好玩的代碼,用來顯示本地計算機CPU的使用情況,整理如下,歡迎使用,更多信息請瀏覽應屆畢業生考試網!

              using System;

              using System.Diagnostics;

              using System.Threading;

              namespace ConsoleApplication1

              {

              class Program

              {

              private const string CategoryName = "Processor";

              private const string CounterName = "% Processor Time";

              private const string InstanceName = "_Total";

              private static void OutPut(string txt)

              {

              Console.WriteLine(txt);

              }

              [STAThread]

              public static void Main()

              {

              PerformanceCounter pc = new PerformanceCounter(CategoryName, CounterName, InstanceName);

              OutPut("----------------------------開始創造性能計數器----------------------------");

              OutPut("計數器類型:" + pc.CounterType);

              OutPut("計數器的說明:" + pc.CounterHelp);

              OutPut("開始輸出:");

              while (true)

              {

              Thread.Sleep(1000);

              float cpuLoad = pc.NextValue();

              OutPut("CPU 耗用:" + cpuLoad + "%");

              }

              }

              }

              }

              直接運行程序,對比控制臺輸出的結果與計算機的Windows任務管理器中顯示的CPU使用值,會發現原來Windows任務管理器顯示的值是CPU使用率的四舍五入的結果。有興趣的朋友可以自己復制代碼試試看啦。

            【利用C#監控計算機CPU的使用率】相關文章:

            c#檢測cpu使用率09-01

            用C#語言獲取CPU利用率06-24

            CPU使用率過高的解決方法08-30

            cpu使用率高怎么辦09-07

            cpu使用率100怎么辦11-01

            CPU使用率高的原因及解決方法09-24

            CPU使用率過高是什么原因10-22

            電腦cpu使用率很高怎么辦08-11

            造成CPU使用率100%原因有哪些09-09

                    <pre id="bbfd9"><del id="bbfd9"><dfn id="bbfd9"></dfn></del></pre>

                    <ruby id="bbfd9"></ruby><p id="bbfd9"><mark id="bbfd9"></mark></p>

                    <p id="bbfd9"></p>

                    <p id="bbfd9"><cite id="bbfd9"></cite></p>

                      <th id="bbfd9"><form id="bbfd9"><dl id="bbfd9"></dl></form></th>

                      <p id="bbfd9"><cite id="bbfd9"></cite></p><p id="bbfd9"></p>
                      <p id="bbfd9"><cite id="bbfd9"><progress id="bbfd9"></progress></cite></p>
                      飘沙影院