I need to write a class that will attach to certain windows processes, monitor and limit their cpu usage. Process priority changing would not help me at all so i really need to write a program that is basically similar to BES or ThreadMaster. So i need to make a class that's doing something like this (pseudo code):
public void cpuLimiter(pid)
{
ProcessHandle handle = attachToProcess(pid);
while (cpuLimiting)
{
if (handle.cpuUsage > 30%)
{
handle.sleep(100miliseconds);
}
sleep(10miliseconds);
}
closeHandle(pid);
}
I hope i made it clear what i want to accomplish, just i have no idea how. Every help is appreciated.
beg you for the most complete codeThis kind of makes it sound like you want us to just spoon-feed you a solution rather than addressing a specific problem with code you've written. The latter is a good question, the former is not. Please show what you've tried.