From 174b0743a992a5c95266f297d0fbf968b60919cb Mon Sep 17 00:00:00 2001 From: Adam Honse Date: Sat, 25 Jul 2020 01:51:39 -0500 Subject: [PATCH] Update timer resolution every 500ms to ensure it stays set while OpenRGB is active --- main.cpp | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/main.cpp b/main.cpp index ea45ae52..12c2a48a 100644 --- a/main.cpp +++ b/main.cpp @@ -15,6 +15,7 @@ #include #include #include +#include #include "OpenRGBDialog2.h" @@ -63,6 +64,16 @@ void InitializeTimerResolution() NtSetTimerResolution(5000, TRUE, &CurrentResolution); } + +void InitializeTimerResolutionThreadFunction() +{ + while(1) + { + InitializeTimerResolution(); + + std::this_thread::sleep_for(500ms); + } +} #endif /******************************************************************************************\ @@ -118,7 +129,9 @@ bool AttemptLocalConnection() int main(int argc, char* argv[]) { #ifdef _WIN32 - InitializeTimerResolution(); + std::thread * InitializeTimerResolutionThread; + InitializeTimerResolutionThread = new std::thread(InitializeTimerResolutionThreadFunction); + InitializeTimerResolutionThread->detach(); #endif ProfileManager profile_manager(rgb_controllers);