一个监视cpu使用情况的小程序,可以运行,但没有显示cpu的使用情况.也没有报错,添加了performanceCounter1控件属性设置为CategoryName=Processor.
ConunterName=%Processor Time. InstanceName=_Total和time1控件,属性设置为Interval=10000.这是怎么回事呀??先谢大家了.using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;namespace cpu
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }        private void Form1_Load(object sender, EventArgs e)
        {        }        private void timer1_Tick(object sender, EventArgs e)
        {
            progressBar1.Value = (int)(performanceCounter1.NextValue());
            label1.Text = "Processor Time: " + progressBar1.Value.ToString() + "%";                         }            }
}
        

解决方案 »

  1.   

    timer 控件的Enabled 属性设置为 true
      

  2.   

    另外你的Interval=10000 是10秒更新一下, 设置小一点
    容易看效果
      

  3.   

    生成一个和你同样的工程,timer 控件的Enabled 属性设置为 true ,有效果哦
      

  4.   

    progressBar1.Value = (int)(performanceCounter1.NextValue());
                label1.Text = "Processor Time: " + progressBar1.Value.ToString() + "%";
    =======================================================
    这样写应该不会变化的吧