473,814 Members | 3,010 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

performance counter problem

Hello,

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

following code:
PerformanceCoun terCategory cat = new PerformanceCoun terCategory("Pr ocess");

foreach (string instance in cat.GetInstance Names())
{
PerformanceCoun ter counter = new PerformanceCoun ter("Process"," %
Processor Time",instance) ;
this.listBox1.I tems.Add(instan ce + ":" + counter.NextVal ue());
}

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

"Dirk Reske" wrote...
foreach (string instance in cat.GetInstance Names())
{
PerformanceCoun ter counter =
new PerformanceCoun ter("Process"," %Processor Time",instance) ;
this.listBox1.I tems.Add(instan ce + ":" + counter.NextVal ue());
}

why does counter.NextVal ue() 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.RawValu e?

// 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 PerformanceCoun ter Category "Process"

thx

"Bjorn Abelli" <bj**********@D oNotSpam.hotmai l.com> schrieb im Newsbeitrag
news:Oc******** ******@TK2MSFTN GP11.phx.gbl...

"Dirk Reske" wrote...
foreach (string instance in cat.GetInstance Names())
{
PerformanceCoun ter counter =
new PerformanceCoun ter("Process"," %Processor Time",instance) ;
this.listBox1.I tems.Add(instan ce + ":" + counter.NextVal ue());
}

why does counter.NextVal ue() 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.RawValu e?

// Bjorn A

Nov 16 '05 #4

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

Similar topics

0
1565
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 empty, whenever the focus leave it, pop up error message. In Chapter 2 lesson 3 of Developing XML Web Services and Server Components with Microsoft Visual Basic.NET and Microsoft VIsual C#.net book, there is a note saying "By default the designer also...
2
1038
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 configurations and be able to start and stop the logging through my application. I have done some digging, but have not been able to figure how I would do this from C#.
0
1757
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: PerformanceCounter perfCounter = new PerformanceCounter("TCP","Connections Active");
1
3308
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 is running in a web-farm environment of multiple web servers. We have been using "Performance Monitor" to monitor the "Requests in Application Queue" counter of "ASP.NET Apps v.1.1.4322" object. We have found the following pattern.
0
1537
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" Instance name = "_Total" That works great / however when I use the following counter it returns some incorrect data. Category Name = "Web Service"
7
4814
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 counters all show 0. In addition, ASP.NET Applications does not show any of the ASP.NET instances that are running on the computer. The other counters for example % processor time work fine. The problem machine is a test server running Win2003. ...
17
2072
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 to access the page, it takes really long time to load. However, after up to 1 hour, the website will run fine again as normal. This issue has been there with the site. I usually just ask the system admin to restart the IIS Service. However, the...
1
2459
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 .Net 2.0) The performance counter categories have been successfully created. When the set of classes are used by a WinForm test harness application, they function as expected, and the performance counters can be seen to be updated by using the...
30
3556
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
3140
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
9609
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10669
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10408
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10426
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10141
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9225
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7686
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
1
4358
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3886
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.