首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > C# >

C#小疑点?

2012-01-16 
C#小问题??在线等....一个监视cpu使用情况的小程序,可以运行,但没有显示cpu的使用情况.也没有报错,添加了p

C#小问题??在线等....
一个监视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()   +   "% ";

                                                  }

                        }
}
               


[解决办法]
timer 控件的Enabled 属性设置为 true
[解决办法]
另外你的Interval=10000 是10秒更新一下, 设置小一点
容易看效果

热点排行