To create a new category and set of performance counters programmatically:
代码
// Create a collection of type CounterCreationData
var collection = new CounterCreationDataCollection();
// Create the counter and set its properties.
var data = new CounterCreationData("Number Of Items""...", PerformanceCounterType.NumberOfItems32);
// Add counter to the collection.
collection.Add(data);
// Create the category and pass the collection to it.
PerformanceCounterCategory.Create(
    
"DimecastDeme",
    
"",
    PerformanceCounterCategoryType.MultiInstance,
    collection);
// Get the counter already been created (Counter Name: Number of Items; Category: DimecastDeme)
var counter = new PerformanceCounter("DimecastDeme""Number Of Items""Demo"false);
// set value
counter.RawValue = 1;
counter.IncrementBy(
2);
counter.IncrementBy(
4);

Reference:
http://msdn.microsoft.com/en-us/library/5e3s61wf.aspx
http://www.techscreencast.com/language/dotnet/how-to-create-a-custom-performance-counter/1856

 

相关文章:

  • 2022-02-07
  • 2021-11-21
  • 2022-02-28
  • 2022-12-23
  • 2022-01-23
  • 2021-08-08
  • 2021-08-20
猜你喜欢
  • 2022-03-02
  • 2021-10-23
  • 2022-12-23
  • 2022-12-23
  • 2022-03-08
相关资源
相似解决方案