由于某种原因,我的性能计数器不工作。我看到这个性能计数器在其他人的笔记本电脑上工作;桌面,但不是我的。
它没有让我选择的列表,其他人根本没有这个问题。即使我从服务器管理器中捕捉到它,并将其放到表单中,它仍然显示“System.Diagnostic.PerformanceCounter”,这非常恼人。
using System;
using System.Diagnostics;
using Microsoft.WindowsAzure.Diagnostics;
namespace MonitorC
{
public partial class Form1 : MetroFramework.Forms.MetroForm
{
//PerformanceCounter perfCPUCounter = new PerformanceCounter("Processor Information", "% Processor Time", "_Total");
//PerformanceCounter perfRAMCounter = new PerformanceCounter("Memory", "Available MBytes");
//PerformanceCounter perfSysCounter = new PerformanceCounter("System", "System Up Time");
public Form1()
{
InitializeComponent();
}
private void timer1_Tick(object sender, EventArgs e)
{
CPUusage.Text = performanceCounter1.ToString();
RAMusage.Text = performanceCounter2.ToString();
}
private void Form1_Load(object sender, EventArgs e)
{
timer1.Start();
}
}
}
第一张图片:
第二张图片:
第三张图片:
我拥有的代码: