Skip to content

Commit 8bb81ff

Browse files
committed
Fix Windows priorities.
1 parent 1a9e141 commit 8bb81ff

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

SerialPrograms/Source/CommonFramework/Environment/Environment_Windows.tpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -44,36 +44,36 @@ const EnumDropdownDatabase<ThreadPriority>& PRIORITY_DATABASE(){
4444
}
4545

4646
bool set_thread_priority(Logger& logger, ThreadPriority priority){
47-
DWORD native_priority;
47+
int native_priority;
4848
switch (priority){
4949
case ThreadPriority::Realtime:
50-
native_priority = REALTIME_PRIORITY_CLASS;
50+
native_priority = THREAD_PRIORITY_TIME_CRITICAL;
5151
break;
5252
case ThreadPriority::High:
53-
native_priority = HIGH_PRIORITY_CLASS;
53+
native_priority = THREAD_PRIORITY_HIGHEST;
5454
break;
5555
case ThreadPriority::AboveNormal:
56-
native_priority = ABOVE_NORMAL_PRIORITY_CLASS;
56+
native_priority = THREAD_PRIORITY_ABOVE_NORMAL;
5757
break;
5858
case ThreadPriority::Normal:
59-
native_priority = NORMAL_PRIORITY_CLASS;
59+
native_priority = THREAD_PRIORITY_NORMAL;
6060
break;
6161
case ThreadPriority::BelowNormal:
62-
native_priority = BELOW_NORMAL_PRIORITY_CLASS;
62+
native_priority = THREAD_PRIORITY_BELOW_NORMAL;
6363
break;
6464
case ThreadPriority::Low:
65-
native_priority = IDLE_PRIORITY_CLASS;
65+
native_priority = THREAD_PRIORITY_IDLE;
6666
break;
6767
default:
6868
throw InternalProgramError(nullptr, PA_CURRENT_FUNCTION, "Invalid Priority: " + std::to_string((int)priority));
6969
}
70-
if (SetPriorityClass(GetCurrentThread(), native_priority)){
70+
if (SetThreadPriority(GetCurrentThread(), native_priority)){
7171
// cout << "Thread priority set to: " + PRIORITY_DATABASE().find(priority)->display << endl;
7272
logger.log("Thread priority set to: " + PRIORITY_DATABASE().find(priority)->display, COLOR_BLUE);
7373
return true;
7474
}
7575
DWORD error = GetLastError();
76-
logger.log("Unable to set process priority. Error Code = " + std::to_string(error), COLOR_RED);
76+
logger.log("Unable to set thread priority. Error Code = " + std::to_string(error), COLOR_RED);
7777
return false;
7878
}
7979

0 commit comments

Comments
 (0)