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 7946413
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T01:08:42+00:00 2026-06-04T01:08:42+00:00

I’m writing a small winforms application that opens several instances of another program. To

  • 0

I’m writing a small winforms application that opens several instances of another program.
To optimize performance I’m looking for a way to find the least used CPU core to assign the process to.

I’d also like to be able to see the usage % of each core. Nothing fancy, a TextBox or Label is fine.

I’ve been trying to use PerformanceCounter after coming across these answers:

Finding core number

CPU usage for more than 2 cores

I tried implementing these as follows:

        StatusBarOutput.Text = "";
        //ignoring posible hyper-threading for simplicity's sake
        var coreUsages = new PerformanceCounter[Environment.ProcessorCount];

        for (var i = 0; i < coreUsages.Length; i++)
        {
            coreUsages[i] = new PerformanceCounter("Processor", "% Processor Time", i.ToString());

            //using the status bar as output for now, doesn't really matter
            StatusBarOutput.Text += "   |   " + coreUsages[i].CounterName + " ~ " + coreUsages[i].NextValue();
        }

The output I’m getting is:

output

Meanwhile, the Task manager is showing this:

output

Not sure what I’m missing here.

  • 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-04T01:08:43+00:00Added an answer on June 4, 2026 at 1:08 am

    The OS is likely much better at determining which core to use. The folks at MS have spent a lot of time optimizing this particular aspect.

    If you try to take it over, are you going to maintain this for every new service pack, version of OS, hardware flavor, etc?

    Your best bet is likely to spend some time optimizing the processes, not trying to outguess the OS.

    UPDATE:

    With performance counters, it’s not quite as simple as just grabbing the first value you find. You need to poll at least twice (with some time in between) to get a value.

    This isn’t necessarily how I would implement this in a real world scenario, but here is the idea:

    var coreUsages = new PerformanceCounter[Environment.ProcessorCount];
    
    for (var i = 0; i < coreUsages.Length; i++)
    {
         coreUsages[i] = new PerformanceCounter("Processor", "% Processor Time", i.ToString());
         coreUsages[i].NextValue();
    }
    
    Thread.Sleep(1000);
    
    for (var i = 0; i < coreUsages.Length; i++)
    {
         //using the status bar as output for now, doesn't really matter
         Trace.WriteLine("   |   " + coreUsages[i].CounterName + " ~ " + coreUsages[i].NextValue());
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I used javascript for loading a picture on my website depending on which small
I have a jquery bug and I've been looking for hours now, I can't
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I've got a string that has curly quotes in it. I'd like to replace
I have a French site that I want to parse, but am running into
I am doing a simple coin flipping experiment for class that involves flipping a
I need a function that will clean a strings' special characters. I do NOT

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.