If it is a timeout, it should be waiting for min (time until next
timeout, gui keep alive delta).
Sorry, I've no idea what that means. Care to explain?
If you want the wait to be for some value other than 10ms,
that's fine with me. I was trying to make the mininum change
possible while still meeting my goal of not sucking up all of
the CPU time. How long do you want it? 20ms? 50ms? 100ms?
Much longer than 100ms is probably going to be noticable.
The code appears to be implementing a timer using polling. Something
somewhere must know the intended timer frequency and hence the sleep
should be the minimum of: