Click here to Skip to main content
15,886,519 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Greetings :)
I have an application named Test.exe. Inside this application I can immediately get its own name and process ID like this:

string processName = Process.GetCurrentProcess().ProcessName;

int processID = Process.GetCurrentProcess().Id;

Using performance counters, inside Test.exe, I can get the CPU load of itself using the application name.

Now for the point. I run 10 instances of Test.exe. Each one has its own separate PID or process Identification Number assigned to it by the OS. I need to let each application of Test.exe sample it's own CPU load. Therefore I have to detect CPU load via the PID since there are 10 instances of the same application running.

Any pointers or samples much appreciated. :)
Posted

1 solution

Have a look at this[^] answer. As far as I can see, it would help you to locate the correct process and corresponding counter instance.
 
Share this answer
 
Comments
radnix 12-Sep-15 13:34pm    
This was a great answer that lead me to this solution that is a great tutorial and working example. Thanks Mika :) :
http://weblog.west-wind.com/posts/2014/Sep/27/Capturing-Performance-Counter-Data-for-a-Process-by-Process-Id#Tryingitout
Wendelius 12-Sep-15 13:36pm    
Glad it helped :)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900