Is there any additional configuration before I can prioritize threads in a windows service?
In my service, I have several threads, each of which calls the CreateProcess() function to start an external application. I would like to prioritize threads (or processes) to normal or lower , depending on some other factors.
The problem is that the SetThreadPriority() function does not work with error 6 (invalid handle?). I pass in the descriptor obtained from PROCESS_INFORMATION::hThread (after calling CreateProcess() , of course), so I believe that the descriptor should be valid.
I also tried to set the priority for processes using the SetPriorityClass() function, which also fails.
The service is registered as a local user.
source share