performance counter instance

  • Thread starter Kristofer Andersson
  • Start date
K

Kristofer Andersson

How do I create a new instance in a performance counter category? The
PerformanceCounterCategory class only has InstanceExists but I can not find
a way to create a new instance..?
 
R

Rajasi Saha

Try -

PerformanceCounter instance = new PerformanceCounter("Category name",
"counter name", "instance name", false);
Note that the instance won't actually show up until it first gets a value.

rajasi
 
G

Gurudev

performancecounter is different from performancecountercategory, you can
only create new performance counter
 
K

Kristofer Andersson

Yup, that is what I am doing. But I got confused by a bug in the
PerformanceCounter class or Windows. If a counter has been created and
received a value without instance name and is subsequently created with
instance name and get a value, the named instance will not be created. After
a reboot of the machine and creating instance name only counters it works.
 
R

Rajasi Saha

I don't know that that is a bug. When you create a counter and don't specify
the instance name, a single instance counter is created. You won't then be
able to create other instances.
 
K

Kristofer Andersson

Yup, but if it can't be created shouldn't the framework at least throw an
exception?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top