I've managed to create a performance category with a single counter in it. I
then try to create instances of this counter, but when I go into perfmon, I
can't see any instances. And the category itself says it hasn't got any
instances when I call GetInstanceNames() on it.
What am I doing wrong?
Here's the bit of code I am using to do this stuff:
CounterCreationDataCollection counterData = new
CounterCreationDataCollection();
counterData.Add(new CounterCreationData(
"Counter",
"Something",
PerformanceCounterType.NumberOfItems32));
PerformanceCounterCategory.Create("Temp", "This is a sandbox", counterData);
PerformanceCounter.CloseSharedResources();
new PerformanceCounter("Temp", "Counter", "The Instance", false).RawValue = 0;
new PerformanceCounter("Temp", "Counter", "Another Instance",
false).RawValue = 0;
PerformanceCounter.CloseSharedResources();