I really had a job trying to figure it out a few years ago. It turns out that this is a very, very difficult task - these days you canβt even trust the OS, so working in an isolated .net environment will make it almost impossible to determine what is actually happening.
Here are a few simple situations that you might want to consider if you decide to continue this.
CPU - you can determine the current CPU usage, but how do you say if your particular instance was tied to a single processor? How do you determine if you are working in a cluster or what other kernels can run? Perhaps you are running a virtual machine with a limited number of processors or threads - these restrictions can be changed on the fly.
Memory - what if you work inside a virtualized instance? What to do if suddenly an external change increases or decreases the amount of available memory?
chris source share