I am trying to get the NextValue
of a PerformanceCounter
class using PhysicalDisk
. Some reason that I can't seem to find out why, it return's 0
every time.
PerformanceCounter pcDiskTime = new PerformanceCounter("PhysicalDisk", "% Disk Time", "_Total");
Single sinDisk = pcDiskTime.NextValue(); //returns 0.0
Using the above and calling pcDiskTime.NextValue
return's 0
. I have other counter's that are working just fine and return what I need.
.RawValue
does return something, but is not the value I would need. Is there something obvious that I am not doing?
Note: I have verified through Performance Monitor
these are indeed the correct category, counter name and instance name. I have also tried to call .NextValue()
twice as sometimes the first return's 0.0
, but this does not help.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…