Jr Carreiro

Jr Carreiro

  • NA
  • 10
  • 1.1k

Working with CPU rate limits with C#

Jan 19 2021 11:19 AM
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)