1
Answer

Working with CPU rate limits with C#

Jr Carreiro

Jr Carreiro

4y
1.1k
1
I'm trying to reproduce some codes that I have in C++, but when I try to work with CPU control I can't reproduce them without the use [DLL Imports], but I would like to do everything using C# native code, without the need to do any references or imports WIN32 API.
Below the code that I tried to reproduce:

 JOBOBJECT_CPU_RATE_CONTROL_INFORMATION info;
 
 
// CPU rate control
info.CpuRate = atoi(argv[2]) * 100;
info.ControlFlags = JOB_OBJECT_CPU_RATE_CONTROL_ENABLE | JOB_OBJECT_CPU_RATE_CONTROL_HARD_CAP;
if (!SetInformationJobObject(hJob, JobObjectCpuRateControlInformation, &info, sizeof(info)))
return Error("Failed in setting job information");
Answers (1)