473,472 Members | 2,211 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

performance counter problem

Hello,

I have following code:
Nov 16 '05 #1
3 3778
sorry...

following code:
PerformanceCounterCategory cat = new PerformanceCounterCategory("Process");

foreach (string instance in cat.GetInstanceNames())
{
PerformanceCounter counter = new PerformanceCounter("Process","%
Processor Time",instance);
this.listBox1.Items.Add(instance + ":" + counter.NextValue());
}

why does counter.NextValue() allways returns 0??
Nov 16 '05 #2

"Dirk Reske" wrote...
foreach (string instance in cat.GetInstanceNames())
{
PerformanceCounter counter =
new PerformanceCounter("Process","%Processor Time",instance);
this.listBox1.Items.Add(instance + ":" + counter.NextValue());
}

why does counter.NextValue() allways returns 0??


"If the calculated value of a counter depends on two counter reads, the
first read returns 0.0." [from documentation]

Perhaps you're really looking for counter.RawValue?

// Bjorn A

Nov 16 '05 #3
can someone give some example code, how I can read out the cpu usage of each
running process?
Its in the PerformanceCounter Category "Process"

thx

"Bjorn Abelli" <bj**********@DoNotSpam.hotmail.com> schrieb im Newsbeitrag
news:Oc**************@TK2MSFTNGP11.phx.gbl...

"Dirk Reske" wrote...
foreach (string instance in cat.GetInstanceNames())
{
PerformanceCounter counter =
new PerformanceCounter("Process","%Processor Time",instance);
this.listBox1.Items.Add(instance + ":" + counter.NextValue());
}

why does counter.NextValue() allways returns 0??


"If the calculated value of a counter depends on two counter reads, the
first read returns 0.0." [from documentation]

Perhaps you're really looking for counter.RawValue?

// Bjorn A

Nov 16 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: william | last post by:
Hi, I'm playing windows service using vb.net. I added a performance counter to my windows service, but I couldn't set MachineName property of the performance counter to blank. After I set it to...
2
by: David Wagner | last post by:
Hi, I am looking at wanting to configure and manage some Performance Monitor logs through a C# application. Specifically, I want to be able to define and configure named performance log...
0
by: Christopher Attard | last post by:
Hi, I want to make use of the Performance Counter "Connections active" which falls under the "TCP" Performance object. I'm using the following code (in C#) to get the performance counter: ...
1
by: Dominic | last post by:
Hi all, We've just migrated to IIS 6.0 / Windows Server 2003. We are now experiencing some stability problem what we did not experience in IIS 5.0 / Windows 2000 Server. Our ASP.NET application...
0
by: jimiz | last post by:
I have a question on how the performance counter instance returns values. I have an app that uses the performance counter for Category name = "Web Service" Counter name = "Current Connections"...
7
by: James | last post by:
Hi Has anybody had any experience of ASP.Net performance counters not updating. In the performance monitor application when I try to add the groups ASP.NET and ASP.NET Applications the...
17
by: 57R4N63R | last post by:
I'm currently building a website for one of the client. There has been few errors here and there, but just recently the problem is getting worse. Basically the symptoms is that when the user try...
1
by: jvn | last post by:
I am experiencing a particular problem with performance counters. I have created a set of classes, that uses System.Diagnostics.PerformanceCounter to increment custom performance counters (using...
30
by: galiorenye | last post by:
Hi, Given this code: A** ppA = new A*; A *pA = NULL; for(int i = 0; i < 10; ++i) { pA = ppA; //do something with pA
6
by: sony.m.2007 | last post by:
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
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.