DotNetNewsgroup.com  
web access to complete list of Microsoft.NET newsgroups
   home   |   control panel login   |   archive  |  
 
  carried group
academic
adonet
aspnet
aspnet.announcements
aspnet.buildingcontrols
aspnet.caching
aspnet.datagridcontrol
aspnet.mobile
aspnet.security
aspnet.webcontrols
aspnet.webservices
assignment_manager
datatools
dotnet.distributed_apps
dotnet.general
dotnet.myservices
dotnet.nternationalization
dotnet.scripting
dotnet.security
dotnet.vjsharp
dotnet.vsa
dotnet.xml
dotnetfaqs
framework
framework.clr
framework.compactframework
framework.component_services
framework.controls
framework.databinding
framework.drawing
framework.enhancements
framework.interop
framework.odbcnet
framework.performance
framework.remoting
framework.sdk
framework.setup
framework.webservices
framework.windowsforms
framework.wmi
frwk.windowsforms.designtime
lang.csharp
lang.jscript
lang.vb
lang.vb.controls
lang.vb.data
lang.vb.upgrade
lang.vc
lang.vc.libraries
  
 
start date: Wed, 8 Aug 2007 22:13:24 +0200,    posted on: microsoft.public.dotnet.framework        back       

Thread Index
  1    Andries Thijssen


Unresponsive performance counters   
If I run the c# code in example 1 the processor time never changes from 0 
(which might be the inital value on my PC). But if I create two separate 
counters as in example 2 (or example 3) the processor shows proper values.
In addition it takes the logical disk counter easily 60 seconds or more to 
adjust to changes on the disk (copying & deleting a large file) (Windows XP 
SP2) . However, perfmon suffers from the same lag, so this might well be OS 
related.

Regards,

Andries

======== Example 1

PerformanceCounter myCounter = new PerformanceCounter();
while (true)
{
myCounter.CategoryName = "LogicalDisk";
myCounter.CounterName = "% Free Space";
myCounter.InstanceName = "C:";
Console.WriteLine("> " + myCounter.NextValue() );
myCounter.CategoryName = "Processor";
myCounter.CounterName = "% Processor Time";
myCounter.InstanceName = "_Total";
Console.WriteLine("> " + myCounter.NextValue() );
Thread.Sleep( 1000 );
}
======== Example 2
PerformanceCounter myCounter = new PerformanceCounter();
PerformanceCounter myCounter2 = new PerformanceCounter();

while (true)
{
myCounter.CategoryName = "LogicalDisk";
myCounter.CounterName = "% Free Space";
myCounter.InstanceName = "C:";
Console.WriteLine("> " + myCounter.NextValue() );
myCounter2.CategoryName = "Processor";
myCounter2.CounterName = "% Processor Time";
myCounter2.InstanceName = "_Total";
Console.WriteLine("> " + myCounter2.NextValue() );
Thread.Sleep( 1000 );
}
======== Example 3
PerformanceCounter myCounter = new PerformanceCounter();
PerformanceCounter myCounter2 = new PerformanceCounter();
myCounter.CategoryName = "LogicalDisk";
myCounter.CounterName = "% Free Space";
myCounter.InstanceName = "C:";
myCounter2.CategoryName = "Processor";
myCounter2.CounterName = "% Processor Time";
myCounter2.InstanceName = "_Total";

while (true)
{
Console.WriteLine("> " + myCounter.NextValue() );
Console.WriteLine("> " + myCounter2.NextValue() );
Thread.Sleep( 1000 );
}
Date:Wed, 8 Aug 2007 22:13:24 +0200   Author:  

Google
 
Web dotnetnewsgroup.com


COPYRIGHT ?2005, EUROFRONT WORLDWIDE LTD., ALL RIGHT RESERVE  |   Contact us