Thanks Greg!
The link cleared up a lot. It works!
Regards,
Martijn
PS For those who are looking for the same answer:
What I did not understand before was that you actually need two performance
counters, a XXXBase (denominator) and an AverageXXX (nominator):
// Add the counter.
CounterCreationData rawFraction = new CounterCreationData();
rawFraction.CounterType =
PerformanceCounterType.AverageCount64;
rawFraction.CounterName = averageCounterName;
CCDC.Add(rawFraction);
// Add the base counter.
CounterCreationData rawFractionBase = new
CounterCreationData();
rawFractionBase.CounterType =
PerformanceCounterType.AverageBase;
rawFractionBase.CounterName = averageCounterNameBase;
CCDC.Add(rawFractionBase);
The averageCounterName now reads [rawFractionCounter].rawvalue /
[rawFractionBase].rawvalue.
______________________________
[quoted text, click to view] "Greg Young" wrote:
> Better might be to look at AverageXXX performance counters
> ....CountPerTimeInterval sounds particularly useful for you in this case.
>
http://www.informit.com/guides/content.asp?g=dotnet&seqNum=254 gives some
> examples. The RawFraction type (also included in that article) is exactly
> what you describe below.
>
> Cheers,
>
> Greg Young
> MVP - C#
>
>
> <vecozo@online.nospam> wrote in message
> news:5CFD9C74-1404-4913-8043-6A97DA0E932A@microsoft.com...
> > Hi,
> >
> > Is it possible to set the double (or perhaps *calculated*) values of a
> > Windows NT performance counter? We use the PerformanceCounter.RawValue
> > property to set counters, such as the total number of requests on a
> > certain
> > application. However, PerformanceCounter.RawValue is of type long but we
> > require to set a double value (e.g. to set an averages). An option would
> > be
> > if we were able to set the denominator and nominator of the calculated
> > value.
> >
> > I hope you be of any assistance.
> >
> > Regards,
> > Martijn Kaag
> >
> >
> > * Background:
> > We are working on a library that instruments our applications. The library
> > collects custom counters ("sources") and every x minutes distributes these
> > collected values to various "sinks" such as a database, a user interface
> > or
> > Windows NT performance counters using the System.Diagnostics namespace.
> > Because we have our own Counter objects that calculate the average,
> > frequency
> > etc we do not use the default PerformanceMonitor.Increment and
> > PerformanceMonitor.IncrementBy methods.
>
>