qr code generator asp net c# The CounterCreationData Class in Visual C#.NET

Create QR Code 2d barcode in Visual C#.NET The CounterCreationData Class

The CounterCreationData Class
Creating QR-Code In C#
Using Barcode printer for VS .NET Control to generate, create QR-Code image in Visual Studio .NET applications.
www.OnBarcode.com
QR Code ISO/IEC18004 Decoder In Visual C#
Using Barcode reader for .NET framework Control to read, scan read, scan image in Visual Studio .NET applications.
www.OnBarcode.com
The CounterCreationData class has one main purpose: it serves as a container object that holds all the pertinent properties that will be needed to create a PerformanceCounter object. The CounterCreationData class has three properties that developers will want to manipulate. These properties are described in Table 10-6.
Painting Bar Code In C#
Using Barcode creator for .NET framework Control to generate, create barcode image in .NET applications.
www.OnBarcode.com
Bar Code Scanner In Visual C#
Using Barcode scanner for .NET Control to read, scan read, scan image in .NET applications.
www.OnBarcode.com
Table 10-6 Properties of the CounterCreationData Class
Quick Response Code Printer In .NET
Using Barcode drawer for ASP.NET Control to generate, create QR Code image in ASP.NET applications.
www.OnBarcode.com
Drawing QR Code ISO/IEC18004 In .NET
Using Barcode encoder for VS .NET Control to generate, create Quick Response Code image in .NET framework applications.
www.OnBarcode.com
Name CounterHelp CounterName CounterType
Denso QR Bar Code Generation In Visual Basic .NET
Using Barcode generation for VS .NET Control to generate, create Quick Response Code image in .NET framework applications.
www.OnBarcode.com
USS-128 Drawer In C#.NET
Using Barcode maker for VS .NET Control to generate, create GS1 128 image in VS .NET applications.
www.OnBarcode.com
Description Retrieves or sets a counter s friendly description Retrieves or sets a counter s name Retrieves or sets a counter s PerformanceCounterType
EAN-13 Maker In Visual C#
Using Barcode encoder for .NET Control to generate, create EAN-13 image in VS .NET applications.
www.OnBarcode.com
Making Code-128 In Visual C#
Using Barcode encoder for .NET Control to generate, create Code 128 Code Set C image in Visual Studio .NET applications.
www.OnBarcode.com
10
DataMatrix Generator In C#.NET
Using Barcode generator for .NET Control to generate, create ECC200 image in .NET applications.
www.OnBarcode.com
Generating MSI Plessey In C#.NET
Using Barcode drawer for .NET framework Control to generate, create MSI Plessey image in Visual Studio .NET applications.
www.OnBarcode.com
Instrumentation
EAN13 Maker In Java
Using Barcode creation for Java Control to generate, create UPC - 13 image in Java applications.
www.OnBarcode.com
Print Code 128A In .NET Framework
Using Barcode creation for ASP.NET Control to generate, create Code 128 Code Set C image in ASP.NET applications.
www.OnBarcode.com
To create a new instance of the CounterCreationData class, do one of the following:
QR Code Creator In Java
Using Barcode maker for Java Control to generate, create QR Code ISO/IEC18004 image in Java applications.
www.OnBarcode.com
Draw QR Code 2d Barcode In Java
Using Barcode encoder for Eclipse BIRT Control to generate, create QR Code 2d barcode image in BIRT applications.
www.OnBarcode.com
Declare a new instance of the object, and set each property manually. Pass in all three properties to the second overloaded constructor.
ANSI/AIM Code 128 Scanner In C#.NET
Using Barcode scanner for .NET framework Control to read, scan read, scan image in .NET applications.
www.OnBarcode.com
Paint UPC-A In None
Using Barcode generator for Online Control to generate, create UPC-A Supplement 5 image in Online applications.
www.OnBarcode.com
The following code snippet demonstrates the first process listed:
Generating Code 3 Of 9 In Java
Using Barcode creator for Java Control to generate, create Code 39 Full ASCII image in Java applications.
www.OnBarcode.com
Barcode Creator In .NET Framework
Using Barcode creation for ASP.NET Control to generate, create bar code image in ASP.NET applications.
www.OnBarcode.com
' VB Dim DemoCounterName As String = "DemoCounter" Dim DemoData As New CounterCreationData() DemoData.CounterName = DemoCounterName DemoData.CounterHelp = "Training Demo Counter" DemoData.CounterType = PerformanceCounterType.SampleCounter // C# String DemoCounterName = "DemoCounter"; CounterCreationData DemoData = new CounterCreationData(); DemoData.CounterName = DemoCounterName; DemoData.CounterHelp = "Training Demo Counter"; DemoData.CounterType = PerformanceCounterType.SampleCounter;
The following code snippet demonstrates the second process listed:
' VB Dim DemoCounterName As String = "DemoCounter" Dim DemoData As New CounterCreationData(DemoCounterName, "Training Demo Counter", PerformanceCounterType.SampleCounter) // C# String DemoCounterName = "DemoCounter"; CounterCreationData DemoData = new CounterCreationData(DemoCounterName, "Training Demo Counter", PerformanceCounterType.SampleCounter );
The PerformanceCounterCategory Class
The main purpose of the PerformanceCounterCategory class is to manage and manipulate PerformanceCounter objects and their categories. It contains the following five static methods, which allow a tremendous amount of control over performance categories:
Create Creates a PerfomanceCounterCategory class Delete Deletes a PerformanceCounterCategory class Exists Determines whether a PerformanceCounterCategory is already in existence GetCategories Lists each of the PerformanceCounterCategories on a given machine ReadCategory Reads all the counter and performance data associated with a given PeformanceCategory
To use the Create method, call the static Create method of the PerformanceCounterCategory class, passing in the CategoryName, CategoryHelp, CategoryType, CounterName,
Lesson 3: Monitoring Performance
and CounterHelp values. Before attempting to call the Create method, the Exists method can be called to verify whether the category exists. (Obviously, if it does, there s no need to re-create it.). The following code checks to see if a given performance counter exists and if not, it creates it.
' VB Dim DemoCategory As New PerformanceCounterCategory("DemoCategory") If Not PerformanceCounterCategory.Exists("DemoCategory") Then PerformanceCounterCategory.Create("DemoCategory", "Training Demo Category", PerformanceCounterCategoryType.SingleInstance, "DemoCounter", "Training Counter Demo") End If // C# PerformanceCounterCategory DemoCategory = new PerformanceCounterCategory("DemoCategory"); if (!PerformanceCounterCategory.Exists("DemoCategory")) { PerformanceCounterCategory.Create("DemoCategory", "Training Demo Category", PerformanceCounterCategoryType.SingleInstance, "DemoCounter", "Training Counter Demo"); }
There is one thing to be careful of with this method. If the Category already exists, an InvalidOperationException will be thrown. To delete a category, all that s needed is to call the Delete method of the PerformanceCounterCategory and pass in the category name, like so:
' VB If PerformanceCounterCategory.Exists("DemoCounter") Then PerformanceCounterCategory.Delete("DemoCounter") End If // C# if (PerformanceCounterCategory.Exists("DemoCounter")) { PerformanceCounterCategory.Delete("DemoCounter"); }
The GetCategories method is the next method in the list, and it simply enables retrieval of all the PerformanceCounterCategory objects on a given machine. By default, it will refer to the PerformanceCounterCategory on the local machine; however, the constructor provides an overload that can specify another machine s name from which the PerformanceCounterCategory objects will be retrieved. Here is an example of using the GetCategories method:
' VB Dim DemoCategories() As PerformanceCounterCategory = PerformanceCounterCategory.GetCategories("machinename")
10
Instrumentation
For Each ThisCategory As PerformanceCounterCategory In DemoCategories() Console.WriteLine(ThisCategory.CategoryName) Next // C# if (PerformanceCounterCategory.Exists("DemoCounter")) { PerformanceCounterCategory[] DemoCategories = PerformanceCounterCategory.GetCategories("m achinename"); foreach (PerformanceCounterCategory ThisCategory in DemoCategories) { Console.WriteLine(ThisCategory.CategoryName); } }
The final method on the list is the ReadCategory method. ReadCategory reads all the counter and performance object instance data that is associated with this category. This method returns an InstanceDataCollectionCollection. (Although the name looks peculiar, this is the actual object name.) This collection can be iterated, and all the available information about a category will be provided. The following code snippet shows how to use the ReadCategory method:
' VB Dim DemoCounterCategory As New PerformanceCounterCategory("MSMQ Service") Dim DemoCollection As InstanceDataCollectionCollection = DemoCounterCategory.ReadCategory For Each ThisCollection As InstanceDataCollection In DemoCollection Debug.WriteLine(ThisCollection.CounterName) Next // C# PerformanceCounterCategory DemoCounterCategory = new PerformanceCounterCategory(); InstanceDataCollectionCollection DemoCollection = DemoCounterCategory.ReadCategory(); foreach (InstanceDataCollection ThisCollection in DemoCollection) { Console.WriteLine(ThisCollection.CounterName); }
Copyright © OnBarcode.com . All rights reserved.