一个监视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() + "%"; } }
}
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() + "%"; } }
}
容易看效果
label1.Text = "Processor Time: " + progressBar1.Value.ToString() + "%";
=======================================================
这样写应该不会变化的吧