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

  • Home
  • SEARCH
  • 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 7368521
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T03:42:31+00:00 2026-05-29T03:42:31+00:00

I am tracking multiple instances of the same application and need to get the

  • 0

I am tracking multiple instances of the same application and need to get the memory and cpu use of both processes. However, I cant seem to figure out a way to use the performance counter and know which result is for which process. I have seen that I can append #1 and such to the end of the name to get results for each, but that doesn’t tell me which one is for which process.

How can I determine the ProcessId or pass the process ID to the counter to get the result per each process with same name?

PerformanceCounterCPU.CategoryName = "Process";
PerformanceCounterCPU.CounterName = "% Processor Time";
PerformanceCounterCPU.InstanceName = proc.ProcessHandle.ProcessName;

PerformanceCounterMemory.CategoryName = "Process";
PerformanceCounterMemory.CounterName = "Working Set - Private";
PerformanceCounterMemory.InstanceName = proc.ProcessHandle.ProcessName;
  • 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-05-29T03:42:54+00:00Added an answer on May 29, 2026 at 3:42 am

    This answer to a related question might work:

    private static string GetProcessInstanceName(int pid)
    {
      PerformanceCounterCategory cat = new PerformanceCounterCategory("Process");
    
      string[] instances = cat.GetInstanceNames();
      foreach (string instance in instances)
      {
    
         using (PerformanceCounter cnt = new PerformanceCounter("Process",  
              "ID Process", instance, true))
         {
            int val = (int) cnt.RawValue;
            if (val == pid)
            {
               return instance;
            }
         }
      }
      throw new Exception("Could not find performance counter " + 
          "instance name for current process. This is truly strange ...");
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there a simple, efficient weak/guarded pointer? I need multiple pointers to the same
For tracking user activity, I am using a Windows Hook for the main application
Working on a tracking application using GPS. It is all fine, but sometimes because
I need to have a command handler for a ToggleButton that can take multiple
With our GA code, we are tracking multiple domains and subdomains, and we have
I have multiple business objects in my application (C#, Winforms, WinXP). When the user
I am currently refactoring an application into multiple classes in an attempt to fulfill
i am using a single instance of Bugzilla for issue tracking in multiple projects.
I'm creating an application (using PHP / Codeigniter / MYSQL) for tracking volunteers at
The problem described below relates to an inventory tracking Java program. There are multiple

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.