Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8451421
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T11:14:08+00:00 2026-06-10T11:14:08+00:00

I have a windows service that has some performance counters in it. I have

  • 0

I have a windows service that has some performance counters in it. I have another application that monitors what the service is doing, including the performance counters that way everything is found and available in one place. However I seem to be having an issue with one of the performance counters of type RateOfCountsPerSecond32. If I look at the counters on Perfmon everything seems fine, this particular counter gives a reasonable value, but in my monitoring application the counter always provides 0 as its NextValue.

Below is the code i’m using to retrieve the counters from the given category:

        PerformanceCounterCategory pcc = new PerformanceCounterCategory(comboBox1.SelectedItem.ToString());

        string stats = string.Empty;

        foreach (var counter in pcc.GetCounters())
        {
            stats += string.Format("{0}:\t {1} : {2}\r\n\r\n", counter.CounterName, counter.NextValue(), counter.RawValue );
        }

        lblTps.Text = stats;

This only seems to be an issue with this particular type of Counter.

Can anyone else notice anything wrong with this? (other than that I should be using a StringBuilder)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T11:14:10+00:00Added an answer on June 10, 2026 at 11:14 am

    From MSDN:

    If the calculated value of a counter depends on two counter reads, the first read operation returns 0.0.

    You have to call NextValue() twice after creating this type of counter because it needs to buffer one sample before computing its first value. Subsequent calls to NextValue() will work as expected.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We currently have an application (Windows service) that connects to another of our applications
I have a windows service that has it's name set by an app.config. I
I have a windows service that does some intensive work every one minute (actually
I have a windows service that generates logs as it does some execution. I
I have a windows service that has a lot of work to do simultaneously.
I have a .net windows service that works it's way through a queue of
I have a Windows service that has a number of threads that all need
I have a windows service that fails to start under some circumstances. When it
I have the following class in a Windows Service that is experiencing some vary
I have a windows service that has tasks and those tasks run a parallel

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.