Update timer resolution every 500ms to ensure it stays set while OpenRGB is active

This commit is contained in:
Adam Honse 2020-07-25 01:51:39 -05:00
parent 4b50533560
commit 174b0743a9

View file

@ -15,6 +15,7 @@
#include <vector>
#include <stdio.h>
#include <stdlib.h>
#include <thread>
#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);