Skip to Main Content
C# Cookbook, 2nd Edition
book

C# Cookbook, 2nd Edition

by Jay Hilyard, Stephen Teilhet
January 2006
Intermediate to advanced content levelIntermediate to advanced
1184 pages
43h 23m
English
O'Reilly Media, Inc.
Content preview from C# Cookbook, 2nd Edition
This is the Title of the Book, eMatter Edition
Copyright © 2007 O’Reilly & Associates, Inc. All rights reserved.
466
|
Chapter 8: Diagnostics
PerformanceCounterCategory.Delete(categoryName);
}
PerformanceCounterCategory appCategory =
PerformanceCounterCategory.Create(categoryName, categoryHelp,
PerformanceCounterCategoryType.SingleInstance, counterCollection);
// Create the counter and initialize it.
PerformanceCounter appCounter =
new PerformanceCounter(categoryName, counterName, false);
appCounter.RawValue = 0;
return (appCounter);
}
Discussion
The first action this method takes is to create the CounterCreationDataCollection
object and CounterCreationData object. The CounterCreationData object is created
using the
counterName, counterHelp, and countertype parameters passed to the
CreateSimpleCounter method. The CounterCreationData object is then added to the
counterCollection.
The ASPNET user account, as well as many other user accounts by
default, prevent performance counters from being read. You can either
increase the permissions allowed for these accounts or use imperson-
ation with an account that has access to enable this functionality.
However, this then becomes a deployment requirement of your appli-
cation. Decreasing security for the
ASPNET account or other user
accounts may very well be frowned upon by IT folks deploying your
application.
If categoryName—a string containing the name
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

C# Cookbook

C# Cookbook

Stephen Teilhet, Jay Hilyard
C# Cookbook

C# Cookbook

Joe Mayo
Head First C#, 4th Edition

Head First C#, 4th Edition

Andrew Stellman, Jennifer Greene

Publisher Resources

ISBN: 0596100639Supplemental ContentCatalog PageErrata