I would like to find a way to loop through all the active processes and do diagnostics checks on them (mem usage, cpu time etc) kinda similar to the task manager.
The problem is broken down into two parts:
I am not sure even in what namespace to go looking about it. Any help / tips / links is grateful.
To list currently running processes, use the ps , top , htop , and atop Linux commands. You can also combine the ps command with the pgrep command to identify individual processes.
You can access the Task Manager by pressing the Ctrl + Alt + Del shortcut keys on your keyboard, then select Task Manager. You can also right-click with your mouse on the Windows Taskbar and select Task Manager.
Use the tasklist command to see the list of running processes in Windows. To view the list of the processes that are currently running, you can use the tasklist command, both in Command Prompt and PowerShell. Type tasklist and press Enter.
The best place to start when monitoring apps is the Task Manager. Launch it from the Start menu or with the Ctrl+Shift+Esc keyboard shortcut. You'll land on the Processes screen. At the top of the table, you'll see a list of all the apps which are running on your desktop.
Finding all of the processes
You can do this through the Process class
using System.Diagnostics; ... var allProcesses = Process.GetProcesses();
Running Diagnostics
Can you give us some more information here? It's not clear what you want to do.
The Process class provides a bit of information though that might help you out. It is possible to query this class for
EDIT
OP mentioned they want to get memory and CPU information. These properties are readily available on the Process class (returned by GetProcesses()). Below is the MSDN page that lists all of the supported properties. There are various memory and CPU ones available that will suite your needs.
http://msdn.microsoft.com/en-us/library/system.diagnostics.process.aspx
Code:
Add this line to your using list:
using System.Diagnostics;
Now you can get a list of the processes with the Process.GetProcesses() method, as seen in this example:
Process[] processlist = Process.GetProcesses(); foreach (Process theprocess in processlist) { Console.WriteLine("Process: {0} ID: {1}", theprocess.ProcessName, theprocess.Id); }
Finding all processes is rather easy actually:
using System.Diagnostics; Process[] processes = Process.GetProcesses(); foreach (Process process in processes) { // Get whatever attribute for process. }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With