S
sony.m.2007
Hi,
I'm using VSTS2008.
I tried to create a performance counter as below.
A simple example of monitoring processor usage (similar to what's seen
in task manager):
Code Snippet
using System;
using System.Diagnostics;
using System.Threading;
namespace PerfmonExample
{
class Program
{
static void Main(string[] args)
{
PerformanceCounter processorUsage = new
PerformanceCounter("Processor", "% Processor Time", "_Total",false);
while (true)
{
Console.WriteLine(processorUsage.NextValue());
Thread.Sleep(2000);
}
}
}
}
When i run the above code, it throws error as "The requested
Performance Counter is not a custom counter, it has to be initialized
as ReadOnly."
What could be the problem for this error?
Thanks,
Sony
I'm using VSTS2008.
I tried to create a performance counter as below.
A simple example of monitoring processor usage (similar to what's seen
in task manager):
Code Snippet
using System;
using System.Diagnostics;
using System.Threading;
namespace PerfmonExample
{
class Program
{
static void Main(string[] args)
{
PerformanceCounter processorUsage = new
PerformanceCounter("Processor", "% Processor Time", "_Total",false);
while (true)
{
Console.WriteLine(processorUsage.NextValue());
Thread.Sleep(2000);
}
}
}
}
When i run the above code, it throws error as "The requested
Performance Counter is not a custom counter, it has to be initialized
as ReadOnly."
What could be the problem for this error?
Thanks,
Sony