I've written a simple application in C that is quite CPU intensive. I run it from a command line, e.g. ".\my_program.exe". I have noticed that when I leave the computer idle, sometimes even if I just focus away from the cmd window, the process effectively pauses. When I click on the cmd window, it resumes regular progress again.
Is there a way I can instruct windows to prioritise such a command?
That is probably happening because of "Quick Edit Mode", as said "Stephan" on the question's comments. Since you are using C, you can deactivate it using the Win32 API, as follows.
HADNLE handle_input;
DWORD console_mode;
handle_input = GetStdHandle(STD_INPUT_HANDLE);
GetConsoleMode(handle_input, &console_mode);
console_mode &= ~ENABLE_QUICK_EDIT_MODE;
console_mode |= ENABLE_EXTENDED_FLAGS;
SetConsoleMode(handle_input, console_mode);
You can also do it manually for a CMD instance, by the following steps. If you want to change the default, just click "Default" instead of "Properties".
UPDATE At the request of the answerer @Schilive I am adding screenshots of the mystifying Settings menu in Windows 11 where I don't see Quick Edit Mode anywhere. --@BobStein