Hello, I'm pretty sure this is known but might as well try, seeing we could use something that isn't a rat or me asking for something (lol :D), so I will show you how you can use Performance Counters to monitor cpu and ram usage. Plus I'm gonna be lazy and make them via coding!
Now before we begin, performance counters aren't only used for monitoring CPU and RAM usage, it can monitor other things too, like Caching, HTTP Services, and even Windows Media Player! It's mostly what you choose and how you use it, but I will be focusing on CPU and RAM usage.
Firstly we need to add the control, but what I'm gonna do is just call it within coding.
This will monitor the total CPU usage, this is fun yeah, but one thing that you can also do is monitor individual cores!
This will monitor the first core, but we want to monitor more! So we're gonna copy and paste it, but we will replace the integer in .InstanceName with "1". This will monitor the second core. We can continue on until 8. I do know that there exists processors with more than 8 cores, but 8 is the highest in consumer based processors (I'm looking at you, AMD. And yes I know, people can buy Xeons if they want, but I stick with 8). Also, I know that if you use this without the amount of cores you're calling for, it will throw an error.
Well, now we need to get the value of it.. so what are we gonna do? We're gonna use a progress bar!
That will tell the progress bar to set its value to the value of the cpu used in the list. You can use this with cores to, but I'm not going over that cause it's the same thing.
Now, we need to monitor RAM usage, so.. New perfcounters!
Almost the same thing, but notice that the category name and counter name is different? It's because it wants to get the percentage of committed bytes in use within the memory class. Etc first grade things, yay I know how to read symbols.
So now we need to get the value from that too.. how do we do it? Same as above!
That's practically the use of Performance Counters to monitor CPU and RAM usage. Now, if you excuse me... I need to figure out how to use the Windows Media Player Category with them.[/code]
I may or may not edit this in the quick future.
Now before we begin, performance counters aren't only used for monitoring CPU and RAM usage, it can monitor other things too, like Caching, HTTP Services, and even Windows Media Player! It's mostly what you choose and how you use it, but I will be focusing on CPU and RAM usage.
Firstly we need to add the control, but what I'm gonna do is just call it within coding.
Code
Dim cpuUsed As New PerformanceCounter With {.CategoryName = "Processor", .CounterName = "% Processor Time", .InstanceName = "_Total"}Code
Dim cpuCore1 As New PerformanceCounter With {.CategoryName = "Processor", .CounterName = "% Processor Time", .InstanceName = "0"}Well, now we need to get the value of it.. so what are we gonna do? We're gonna use a progress bar!
Code
ProgressBar1.Value = cpuUsed.NextValueNow, we need to monitor RAM usage, so.. New perfcounters!
Code
Dim ramTotal As New PerformanceCounter With {.CategoryName = "Memory", .CounterName = "% Committed Bytes In Use"}So now we need to get the value from that too.. how do we do it? Same as above!
Code
ProgressBar1.Value = ramTotal.NextValueThat's practically the use of Performance Counters to monitor CPU and RAM usage. Now, if you excuse me... I need to figure out how to use the Windows Media Player Category with them.[/code]
I may or may not edit this in the quick future.
