Fixed time step game loop I'm writing a Direct2D game in c++ / WinAPI. I need to render things 60 times every a second using fixed time step.

__int64 time_before = 0;
__int64 time_now;
__int64 frequency;
__int64 time_elapsed;
double frameTime;
if (QueryPerformanceFrequency((LARGE_INTEGER*)&amp;frequency)) {
    frameTime = (double)frequency / 60;
    while (true) {
        //process incoming messages here
        QueryPerformanceCounter((LARGE_INTEGER*)&amp;time_now);
        time_elapsed = time_now - time_before;
        if (time_elapsed &gt;= frameTime) {
            //update and render things here:
            time_start = time_before;
        }
    }
}


Are there any problems, or are there any improvements that can be made?
Can't you use a 
std::this_thread::sleep_for(std::chrono::milliseconds(x));
or
nanosleep()?

Using any of the two sleeps the cpu will be free to do anything else that needs doing meanwhile this process is sleeping. Also this way it can controls doing the rendering at a specific rate and it´s not a good idea to use a while(true) without any sleep because it eats up all the processing time.