Jaa


PerformanceMonitor.instanceCount Method

Definition

Returns the instance count, which is the number of processes in the current snapshot.

public:
 virtual int instanceCount();
public virtual int instanceCount ();
abstract member instanceCount : unit -> int
override this.instanceCount : unit -> int
Public Overridable Function instanceCount () As Integer

Returns

The number of processes in the current snapshot.

Remarks

Use the takeSnapshot method to take a snapshot of the currently running processes.

The following example demonstrates the instanceCount method.

static void pvPerformanceMonitorTest(args a) 
{ 
    int i, j; 
    PerformanceMonitorInstance instance; 
    PerformanceMonitorCounter counter1, counter2; 
    PerformanceMonitor pm = new PerformanceMonitor(); 
    // Take a current snapshot of the system. 
    pm.takeSnapshot (); 
    // Traverse all the running processes. 
    for (i= 1; i <= pm.instanceCount(); i++) 
    { 
        instance = pm.instance(i); 
        counter1 = instance.getCounter("ID Process"); 
        counter2 = instance.getCounter("Working Set"); 
        print instance.name(), " ",  
            counter1.intData(), " ",  
            counter2.intData(); 
    } 
    pause; 
}

Applies to