DWORD WINAPI ThreadProc(LPVOID) { ThreadCallback = Stopped; FrameStart = GetTime(); for(;;) { do { Sleep(10); FrameEnd = GetTime(); } while(FrameEnd == FrameStart); ThreadCallback(); assert(SetBkColor(WindowContext, RGB(0, 0, 0)) != CLR_INVALID); assert(SetTextColor(WindowContext, RGB(255, 255, 255)) != CLR_INVALID); if(TimeElapsed >= 86400) TimerStrLen = _snprintf(TimerStr, sizeof(TimerStr), "%02u-%02u:%02u", (unsigned)TimeElapsed/86400%100, (unsigned)TimeElapsed/3600%24, (unsigned)TimeElapsed/60%60); else if(TimeElapsed >= 3600) TimerStrLen = _snprintf(TimerStr, sizeof(TimerStr), "%02u:%02u:%02u", (unsigned)TimeElapsed/3600%24, (unsigned)TimeElapsed/60%60, (unsigned)TimeElapsed%60); else TimerStrLen = _snprintf(TimerStr, sizeof(TimerStr), "%02u:%02u.%02u", (unsigned)TimeElapsed/60%60, (unsigned)TimeElapsed%60, (unsigned)(TimeElapsed*100)%100); assert(TimerStrLen == 8); assert(TextOut(WindowContext, 0, 0, TimerStr, TimerStrLen) != 0); FrameTime = FrameEnd - FrameStart; FrameStart = FrameEnd; FramesSec = 1.0f / FrameTime; } return 0; }
ThreadEventDispatcher::ThreadEventDispatcher(void):mThread(ThreadCallback(ThreadEventDispatcher::ProcessEvents),NULL) { mThread.SetUserData(this); mThread.SetCallback(ThreadCallback(ThreadEventDispatcher::ProcessEvents)); }