Sleep(Time > 0) may cause the thread to sleep for to long due to the window times of the scheduler (16ms on win if i'm not misstaken), a way that quake used that works really well even for unthreaded applications is:

[pascal]
UpdateTime:= GetCurrentTime;
repeat
Sleep(0);

CurentTime:= GetCurrentTime;
until CurentTime- UpdateTime >= UpdateTime;
[/pascal][/pascal]