Putting code in time frames

If I knew how to express myself clearly I'd google this stuff, but I don't. So here it goes: I can call Sleep for, let's say, 10 secs, and then execute some code. The overall time of such operation would be 10s + whatever it took to execute the code. However, what I want is for the code to be executed inside the 10 seconds period and wait for whatever time is left, so I'd have a stable execution period. How do I do that?
assuming its windows:

1. create timer using http://msdn.microsoft.com/en-us/library/windows/desktop/ms632592%28v=vs.85%29.aspx - function SetTimer ( http://msdn.microsoft.com/en-us/library/windows/desktop/ms644906%28v=vs.85%29.aspx ).
2. then use either callback or different thread to work withing this period ( read above references)
Topic archived. No new replies allowed.