Date: 08/14/06 (C Sharp) Keywords: no keywords Could anyone please help me with .NET performance counters?  I am trying to read the % Processor Time of all of the currently running processes on the system.  Here is my code.  Assume that thisInstances is a string array containing elements, each of which is one process running on the system (I checked this myself using the debugger): 
					foreach (string thisInstance in thisInstances)
					{
						thisPerfCounter = new PerformanceCounter();
						thisPerfCounter.CategoryName = "Process";
						thisPerfCounter.CounterName = "% Processor Time";
						thisPerfCounter.InstanceName = thisInstance;
						thisPerfCounter.NextValue();
							System.Windows.Forms.MessageBox.Show(thisInstance + ": " + thisPerfCounter.NextValue().ToString());
						thisPerfCounter.Dispose();
						thisPerfCounter = null;
						thisProcess = null;
					}
I see a messagebox for every process on the system, but each and every one has a value of 0. What gives? I've read articles, copied code from console applications that actually work, etc. I'm not sure what I'm doing wrong. Any suggestions? 
  |