mattKnight
Programmer
Hi all,
another newbie question I'm afraid to do with multi-threading!
I am writing a scheduler routine
brief outline is
1) Read value from registry for activation time
2) compare to current system time & calculate number of seconds until time to activate.
3) enforce a "wait" period on current thread for that time period
steps 1 & 2 are implemented and working ok! (wonder willnever cease
)
howvever to the wait state...
suppose the delay is 3600 secs (1 hour)
Is it better to use
or
hEvent will never get signalled btw
As I see it, the first is likely to be less accurate due to vaugaries of WINNT timing. Is that correct? Will the timing also be dependant on CPU stress?
Using the second outline, delay can be re-evaluated and timing inaccuracies eliminated.
The timings do not [bold]really[/b] have to be precise - but pride dictates that it should be close
Is there another (better) way of wasting time?
Thanks
Matt
another newbie question I'm afraid to do with multi-threading!
I am writing a scheduler routine
brief outline is
1) Read value from registry for activation time
2) compare to current system time & calculate number of seconds until time to activate.
3) enforce a "wait" period on current thread for that time period
steps 1 & 2 are implemented and working ok! (wonder willnever cease
![[bigsmile] [bigsmile] [bigsmile]](/data/assets/smilies/bigsmile.gif)
howvever to the wait state...
suppose the delay is 3600 secs (1 hour)
Is it better to use
Code:
WaitForSingleObject(hEvent, 3600*1000);
Code:
for (int nCount = 0; nCount >3600;nCount++)
{
WaitForSingleObject(hEvent, 1000);
}
As I see it, the first is likely to be less accurate due to vaugaries of WINNT timing. Is that correct? Will the timing also be dependant on CPU stress?
Using the second outline, delay can be re-evaluated and timing inaccuracies eliminated.
The timings do not [bold]really[/b] have to be precise - but pride dictates that it should be close
Is there another (better) way of wasting time?
Thanks
Matt