CounterCreationData Oluşturucular
Tanım
Önemli
Bazı bilgiler ürünün ön sürümüyle ilgilidir ve sürüm öncesinde önemli değişiklikler yapılmış olabilir. Burada verilen bilgilerle ilgili olarak Microsoft açık veya zımni hiçbir garanti vermez.
CounterCreationData sınıfının yeni bir örneğini başlatır.
Aşırı Yüklemeler
CounterCreationData() |
sınıfının yeni bir örneğini CounterCreationData , türündeki |
CounterCreationData(String, String, PerformanceCounterType) |
Belirtilen sayaç adını ve Yardım dizelerini kullanarak sınıfın yeni bir örneğini CounterCreationData belirtilen türdeki bir sayaç için başlatır. |
CounterCreationData()
- Kaynak:
- CounterCreationData.cs
- Kaynak:
- CounterCreationData.cs
- Kaynak:
- CounterCreationData.cs
sınıfının yeni bir örneğini CounterCreationData , türündeki NumberOfItems32
bir sayacına ve boş ad ve yardım dizeleriyle başlatır.
public:
CounterCreationData();
public CounterCreationData ();
Public Sub New ()
Örnekler
Aşağıdaki kod örneği, sınıfının boş bir örneğinin CounterCreationData nasıl oluşturulacağını gösterir. Örnek herhangi bir parametre geçirmediğinden , CounterHelpCounterNameve CounterType özellikleri belirtilmez ve daha sonra tanımlanmalıdır.
#using <System.dll>
using namespace System;
using namespace System::Diagnostics;
int main()
{
CounterCreationDataCollection^ myCol = gcnew CounterCreationDataCollection;
// Create two custom counter objects.
CounterCreationData^ myCounter1 = gcnew CounterCreationData( "Counter1","First custom counter",PerformanceCounterType::CounterDelta32 );
CounterCreationData^ myCounter2 = gcnew CounterCreationData;
// Set the properties of the 'CounterCreationData' Object*.
myCounter2->CounterName = "Counter2";
myCounter2->CounterHelp = "Second custom counter";
myCounter2->CounterType = PerformanceCounterType::NumberOfItemsHEX32;
// Add custom counter objects to CounterCreationDataCollection.
myCol->Add( myCounter1 );
myCol->Add( myCounter2 );
if ( PerformanceCounterCategory::Exists( "New Counter Category" ) )
PerformanceCounterCategory::Delete( "New Counter Category" );
// Bind the counters to a PerformanceCounterCategory.
PerformanceCounterCategory^ myCategory = PerformanceCounterCategory::Create( "New Counter Category", "Category Help", myCol );
Console::WriteLine( "Counter Information:" );
Console::WriteLine( "Category Name: {0}", myCategory->CategoryName );
for ( int i = 0; i < myCol->Count; i++ )
{
// Display the properties of the CounterCreationData objects.
Console::WriteLine( "CounterName : {0}", myCol[ i ]->CounterName );
Console::WriteLine( "CounterHelp : {0}", myCol[ i ]->CounterHelp );
Console::WriteLine( "CounterType : {0}", myCol[ i ]->CounterType );
}
}
using System;
using System.Diagnostics;
namespace MyDiagnostics
{
class MyCounterCreationData
{
static void Main()
{
CounterCreationDataCollection myCol =
new CounterCreationDataCollection();
// Create two custom counter objects.
CounterCreationData myCounter1 = new CounterCreationData("Counter1",
"First custom counter", PerformanceCounterType.CounterDelta32);
CounterCreationData myCounter2 = new CounterCreationData();
// Set the properties of the 'CounterCreationData' object.
myCounter2.CounterName = "Counter2";
myCounter2.CounterHelp = "Second custom counter";
myCounter2.CounterType = PerformanceCounterType.NumberOfItemsHEX32;
// Add custom counter objects to CounterCreationDataCollection.
myCol.Add(myCounter1);
myCol.Add(myCounter2);
if (PerformanceCounterCategory.Exists("New Counter Category"))
PerformanceCounterCategory.Delete("New Counter Category");
// Bind the counters to a PerformanceCounterCategory.
PerformanceCounterCategory myCategory =
PerformanceCounterCategory.Create("New Counter Category", "Category Help",
PerformanceCounterCategoryType.SingleInstance, myCol);
Console.WriteLine("Counter Information:");
Console.WriteLine("Category Name: " + myCategory.CategoryName);
for (int i = 0; i < myCol.Count; i++)
{
// Display the properties of the CounterCreationData objects.
Console.WriteLine("CounterName : " + myCol[i].CounterName);
Console.WriteLine("CounterHelp : " + myCol[i].CounterHelp);
Console.WriteLine("CounterType : " + myCol[i].CounterType);
}
}
}
}
Imports System.Diagnostics
Namespace MyDiagnostics
Class MyCounterCreationData
Shared Sub Main()
Dim myCol As New CounterCreationDataCollection()
' Create two custom counter objects.
Dim myCounter1 As New CounterCreationData("Counter1", "First custom counter", _
PerformanceCounterType.CounterDelta32)
Dim myCounter2 As New CounterCreationData()
' Set the properties of the 'CounterCreationData' object.
myCounter2.CounterName = "Counter2"
myCounter2.CounterHelp = "Second custom counter"
myCounter2.CounterType = PerformanceCounterType.NumberOfItemsHEX32
' Add custom counter objects to CounterCreationDataCollection.
myCol.Add(myCounter1)
myCol.Add(myCounter2)
If PerformanceCounterCategory.Exists("New Counter Category") Then
PerformanceCounterCategory.Delete("New Counter Category")
End If
' Bind the counters to a PerformanceCounterCategory.
Dim myCategory As PerformanceCounterCategory = PerformanceCounterCategory.Create("New " + _
"Counter Category", "Category Help", _
PerformanceCounterCategoryType.SingleInstance, myCol)
Console.WriteLine("Counter Information:")
Console.WriteLine("Category Name: " + myCategory.CategoryName)
Dim i As Integer
For i = 0 To myCol.Count - 1
' Display the properties of the CounterCreationData objects.
Console.WriteLine("CounterName : " + myCol(i).CounterName)
Console.WriteLine("CounterHelp : " + myCol(i).CounterHelp)
Console.WriteLine("CounterType : " + myCol(i).CounterType.ToString())
Next i
End Sub
End Class
End Namespace 'MyDiagnostics
Ayrıca bkz.
Şunlara uygulanır
CounterCreationData(String, String, PerformanceCounterType)
- Kaynak:
- CounterCreationData.cs
- Kaynak:
- CounterCreationData.cs
- Kaynak:
- CounterCreationData.cs
Belirtilen sayaç adını ve Yardım dizelerini kullanarak sınıfın yeni bir örneğini CounterCreationData belirtilen türdeki bir sayaç için başlatır.
public:
CounterCreationData(System::String ^ counterName, System::String ^ counterHelp, System::Diagnostics::PerformanceCounterType counterType);
public CounterCreationData (string counterName, string counterHelp, System.Diagnostics.PerformanceCounterType counterType);
new System.Diagnostics.CounterCreationData : string * string * System.Diagnostics.PerformanceCounterType -> System.Diagnostics.CounterCreationData
Public Sub New (counterName As String, counterHelp As String, counterType As PerformanceCounterType)
Parametreler
- counterName
- String
Kendi kategorisinde benzersiz olması gereken sayacın adı.
- counterHelp
- String
Sayacın davranışını açıklayan metin.
- counterType
- PerformanceCounterType
PerformanceCounterType Sayacın davranışını tanımlayan bir.
Özel durumlar
Numaralandırmanın PerformanceCounterType üyesi olmayan için bir değer counterType
belirttiniz.
counterHelp
, null
değeridir.
Örnekler
Aşağıdaki kod örneği, sınıfının bir örneğinin CounterCreationData nasıl oluşturulacağını ve başlatıldıklarında nesnesinin CounterHelp, CounterName ve CounterType özelliklerini ayarlamak için parametrelerin nasıl geçirilir olduğunu gösterir.
#using <System.dll>
using namespace System;
using namespace System::Diagnostics;
int main()
{
CounterCreationDataCollection^ myCol = gcnew CounterCreationDataCollection;
// Create two custom counter objects.
CounterCreationData^ myCounter1 = gcnew CounterCreationData( "Counter1","First custom counter",PerformanceCounterType::CounterDelta32 );
CounterCreationData^ myCounter2 = gcnew CounterCreationData;
// Set the properties of the 'CounterCreationData' Object*.
myCounter2->CounterName = "Counter2";
myCounter2->CounterHelp = "Second custom counter";
myCounter2->CounterType = PerformanceCounterType::NumberOfItemsHEX32;
// Add custom counter objects to CounterCreationDataCollection.
myCol->Add( myCounter1 );
myCol->Add( myCounter2 );
if ( PerformanceCounterCategory::Exists( "New Counter Category" ) )
PerformanceCounterCategory::Delete( "New Counter Category" );
// Bind the counters to a PerformanceCounterCategory.
PerformanceCounterCategory^ myCategory = PerformanceCounterCategory::Create( "New Counter Category", "Category Help", myCol );
Console::WriteLine( "Counter Information:" );
Console::WriteLine( "Category Name: {0}", myCategory->CategoryName );
for ( int i = 0; i < myCol->Count; i++ )
{
// Display the properties of the CounterCreationData objects.
Console::WriteLine( "CounterName : {0}", myCol[ i ]->CounterName );
Console::WriteLine( "CounterHelp : {0}", myCol[ i ]->CounterHelp );
Console::WriteLine( "CounterType : {0}", myCol[ i ]->CounterType );
}
}
using System;
using System.Diagnostics;
namespace MyDiagnostics
{
class MyCounterCreationData
{
static void Main()
{
CounterCreationDataCollection myCol =
new CounterCreationDataCollection();
// Create two custom counter objects.
CounterCreationData myCounter1 = new CounterCreationData("Counter1",
"First custom counter", PerformanceCounterType.CounterDelta32);
CounterCreationData myCounter2 = new CounterCreationData();
// Set the properties of the 'CounterCreationData' object.
myCounter2.CounterName = "Counter2";
myCounter2.CounterHelp = "Second custom counter";
myCounter2.CounterType = PerformanceCounterType.NumberOfItemsHEX32;
// Add custom counter objects to CounterCreationDataCollection.
myCol.Add(myCounter1);
myCol.Add(myCounter2);
if (PerformanceCounterCategory.Exists("New Counter Category"))
PerformanceCounterCategory.Delete("New Counter Category");
// Bind the counters to a PerformanceCounterCategory.
PerformanceCounterCategory myCategory =
PerformanceCounterCategory.Create("New Counter Category", "Category Help",
PerformanceCounterCategoryType.SingleInstance, myCol);
Console.WriteLine("Counter Information:");
Console.WriteLine("Category Name: " + myCategory.CategoryName);
for (int i = 0; i < myCol.Count; i++)
{
// Display the properties of the CounterCreationData objects.
Console.WriteLine("CounterName : " + myCol[i].CounterName);
Console.WriteLine("CounterHelp : " + myCol[i].CounterHelp);
Console.WriteLine("CounterType : " + myCol[i].CounterType);
}
}
}
}
Imports System.Diagnostics
Namespace MyDiagnostics
Class MyCounterCreationData
Shared Sub Main()
Dim myCol As New CounterCreationDataCollection()
' Create two custom counter objects.
Dim myCounter1 As New CounterCreationData("Counter1", "First custom counter", _
PerformanceCounterType.CounterDelta32)
Dim myCounter2 As New CounterCreationData()
' Set the properties of the 'CounterCreationData' object.
myCounter2.CounterName = "Counter2"
myCounter2.CounterHelp = "Second custom counter"
myCounter2.CounterType = PerformanceCounterType.NumberOfItemsHEX32
' Add custom counter objects to CounterCreationDataCollection.
myCol.Add(myCounter1)
myCol.Add(myCounter2)
If PerformanceCounterCategory.Exists("New Counter Category") Then
PerformanceCounterCategory.Delete("New Counter Category")
End If
' Bind the counters to a PerformanceCounterCategory.
Dim myCategory As PerformanceCounterCategory = PerformanceCounterCategory.Create("New " + _
"Counter Category", "Category Help", _
PerformanceCounterCategoryType.SingleInstance, myCol)
Console.WriteLine("Counter Information:")
Console.WriteLine("Category Name: " + myCategory.CategoryName)
Dim i As Integer
For i = 0 To myCol.Count - 1
' Display the properties of the CounterCreationData objects.
Console.WriteLine("CounterName : " + myCol(i).CounterName)
Console.WriteLine("CounterHelp : " + myCol(i).CounterHelp)
Console.WriteLine("CounterType : " + myCol(i).CounterType.ToString())
Next i
End Sub
End Class
End Namespace 'MyDiagnostics