View Single Post
Old 12th March 2012, 05:28   #16
pumbaa2
Junior Member
 
Join Date: Mar 2012
Posts: 42
Smelter, your code revision has the progress bar update commented out and you updated the sleep delay from 10 to 8... I assume your stream was trailing behind which may suggest it was taking longer than 50ms to update progress bar plus send packets. I found the following "Snooze" cycle:

Do Until timeGetTime - timeRef > 950
DoEvents
Sleep 10
Loop

However, I'm just kinda curious as to why this routine was written that way (I realize you just modified Ken's code and didn't write that yourself)? Is there a reason why I more direct approach wasn't used without the need for a loop, such as:

DoEvents
If timeGetTime < timeRef + 950 then
Sleep (timeRef + 950) - timeGetTime
End If

I assume 950ms was used instead of 1000ms (1 Second) to accommodate for code execution, however, on todays computers it may execute quicker than 50ms. Also "timeRef = timeGetTime" should be "timeRef = timeRef + 1000" (1 Second). This would ensure send timing is exact instead of resetting the reference completely which is sorta "undefined", it maybe +950ms (NSVx gets ahead causing sc_serv buffer overflow), +1000ms (ideal), or +1010ms (NSVx is delayed causing buffering) depending on code execute time which in Windows is REALLY undefined. But it does explain why my scheduler falls slightly out of sync with start times after running for a day or two.

Anyhow, just food for thought...
pumbaa2 is offline   Reply With Quote