高软玩家

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理
   static string NetworkName = new PerformanceCounterCategory("Network Interface").GetInstanceNames()[0];//获取网卡名称
        PerformanceCounter NetworkR = new PerformanceCounter("Network Interface", "Bytes Received/sec", NetworkName);//获取网络接收速度
        PerformanceCounter NetworkS = new PerformanceCounter("Network Interface", "Bytes Sent/sec", NetworkName);
        PerformanceCounter cpu = new PerformanceCounter("Processor", "% Processor Time", "_Total");///CPU性能计数器



  toolStripStatusLabel3.Text = "接收:" + (NetworkR.NextValue() / 1024 / 1024).ToString("0.00") + "mb/s  发送:" + (NetworkS.NextValue() / 1024 / 1024).ToString("0.00") + "mb/s";
            toolStripStatusLabel5.Text = "CPU:" + cpu.NextValue().ToString("0") + "%";

 

posted on 2018-11-07 15:20  高软玩家  阅读(545)  评论(1编辑  收藏  举报