I am developing a C# program, and i have one function that consumes too much CPU. I would like to know a way to control this by code (not with any external application) and
I guess you need to query some kind of OS API to find out how much of the CPU are you consuming and take throttling decisions (like Thread.Sleep) from that on.