You could call NtSuspendProcess
in a loop, suspending it for say 450 ms, and resuming it for 50 ms. Experiments with this on my end seem to have no obvious side effects. When the process comes to the foreground, I disable this loop.
Java example:
boolean inForeground = false;
for(;;) {
updateProcesses(); // updates list of handles to throttle
if(!inForeground) {
for(HANDLE handle : handles.values()) {
NtDll.INSTANCE.NtSuspendProcess(handle);
}
}
Thread.sleep(480);
int foregroundPid = getForegroundPid();
inForeground = false;
for(Map.Entry<Integer, HANDLE> entry : handles.entrySet()) {
NtDll.INSTANCE.NtResumeProcess(entry.getValue());
if(entry.getKey() == foregroundPid) {
inForeground = true;
}
}
Thread.sleep(20);
}
You can use Process Explorer to suspend the process, but I'm not sure that will yield the same result as you expect @lel – Sathyajith Bhat – 2011-02-14T09:43:43.150