Export (0) Print
Expand All

PerformanceCounter.CategoryName Property

Gets or sets the name of the performance counter category for this performance counter.

[Visual Basic]
Public Property CategoryName As String
[C#]
public string CategoryName {get; set;}
[C++]
public: __property String* get_CategoryName();
public: __property void set_CategoryName(String*);
[JScript]
public function get CategoryName() : String;
public function set CategoryName(String);

Property Value

The name of the performance counter category (performance object) with which this performance counter is associated.

Exceptions

Exception Type Condition
ArgumentNullException The CategoryName is a null reference (Nothing in Visual Basic).

Remarks

The CategoryName is displayed in the Performance Object field of Performance Counter Manager MMC snap in's Add Counter dialog box.

A performance counter monitors the behavior of a category, or performance object, on a computer. Categories include physical components (such as processors, disks, and memory) and system objects (such as processes and threads). System counters that are related to the same performance object are grouped into a category that indicates their common focus. When you create an instance of the PerformanceCounter class, you first indicate the category with which the component will interact, and then you choose a counter from that category.

For example, one Windows counter category is the Memory category. System counters within this category track memory data such as the number of bytes available and the number of bytes cached. If you wanted to work with the bytes cached in your application, you would create an instance of the PerformanceCounter component, connect it to the Memory category, and then pick the appropriate counter (in this case, Cached Bytes) from that category.

Although your system makes many more counter categories available, the categories that you will probably interact with most frequently are the Cache, Memory, Objects, PhysicalDisk, Process, Processor, Server, System, and Thread categories.

Example

[Visual Basic] 
Dim PC As New PerformanceCounter()
PC.CategoryName = "Process"
PC.CounterName = "Private Bytes"
PC.InstanceName = "Explorer"
MessageBox.Show(PC.NextValue().ToString())

[C#] 
PerformanceCounter PC=new PerformanceCounter();
PC.CategoryName="Process";
PC.CounterName="Private Bytes";
PC.InstanceName="Explorer";
MessageBox.Show(PC.NextValue().ToString());

[C++] 
PerformanceCounter* PC = new PerformanceCounter();
PC->CategoryName=S"Process";
PC->CounterName=S"Private Bytes";
PC->InstanceName=S"Explorer";
MessageBox::Show(PC->NextValue().ToString());

[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button Language Filter in the upper-left corner of the page.

Requirements

Platforms: Windows NT Server 4.0, Windows NT Workstation 4.0, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family

See Also

PerformanceCounter Class | PerformanceCounter Members | System.Diagnostics Namespace | Process.ProcessName

Show:
© 2014 Microsoft