c++ My timer is unstable Win8.1 VisualStudio -


i not know how make stable timer.

timer did should work every 4ms. did use normal event timer in "wndproc()", "createtimerqueuetimer()",own timer using "std::chrono::high_resolution_clock" , timers unstable. of course use one. calculated @ appointed time or slow make program not smooth. operations not complicated add integers.

createtimerqueuetimer()

if (!createtimerqueuetimer(&hlogictimer, htimerq, (waitortimercallback)window::logicthread, null, 0, 4, null)) return -1; 

window::logicthread() function.

void window::logicthread() {     window::startrender = false;     sc->calculateactors();     window::startrender = true; } 

own function timer called new thread.

bool window::logicthread() {     typedef std::chrono::high_resolution_clock time;     auto start = time::now();     const auto constwait = 4000000;      while (!window::terminaterthread)     {         std::this_thread::sleep_for(std::chrono::nanoseconds(constwait - std::chrono::duration_cast<std::chrono::nanoseconds>(time::now() - start).count()));         start = time::now(); //calculate operation time , sleep thread          window::startrender = false;         sc->calculateactors();         window::startrender = true;     }     return true; } 


Comments

Popular posts from this blog

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -