Even though the timer indicates is can operate down to 1ms intervals the best I can get it to achive is 50ms is this a common problem? Is there any way around it?
Cheers
Printable View
Even though the timer indicates is can operate down to 1ms intervals the best I can get it to achive is 50ms is this a common problem? Is there any way around it?
Cheers
I think the resolution is around 60ms
You could download the SubTimer from http://www.vbaccelerator.com for it has a smaller resolution.
I just found this in the help.
"The system generates 18 clock ticks per second — so even though the Interval property is measured in milliseconds, the true precision of an interval is no more than one-eighteenth of a second. "
This answers my question (1/18)sec = 55ms.
Cheers Azzmodan, I'll have a look on that site.
Rick
[Edited by Rick H on 06-21-2000 at 05:15 AM]
Hi, Rick H Just take a look at this Thread
Chris, I`m not entirley sure on your test routine. I`ve adapted your code slightly to this:
And these are the results I get:Code:Option Explicit
Private T1&, T2&, dl&
Private Declare Function GetTickCount Lib "kernel32" () As Long
Private Declare Function SetTimer Lib "user32" (ByVal hwnd As Long, ByVal nIDEvent As Long, ByVal uElapse As Long, ByVal lpTimerFunc As Long) As Long
Private Declare Function KillTimer Lib "user32" (ByVal hwnd As Long, ByVal nIDEvent As Long) As Long
Public Sub load_SetTimer()
SetTimer frmSome.hwnd, 0, 5, AddressOf TimerProc
T1 = GetTickCount
frmSome.txtoutput = ""
End Sub
Sub TimerProc(ByVal hwnd As Long, ByVal nIDEvent As Long, ByVal uElapse As Long, ByVal lpTimerFunc As Long)
Static a As Integer
Static store(10) As Long
If a <= 10 Then
store(a) = GetTickCount
a = a + 1
Else
KillTimer frmSome.hwnd, 0
For a = 0 To 9
frmSome.txtoutput = frmSome.txtoutput & (store(a) - store(a + 1)) & vbCrLf
Next
a = 0
End If
End Sub
-58
-52
-58
-52
-58
-52
-57
-53
-60
-53
indicating the same 55ms problem as before, this happens even if you change the interval from 5ms to 10ms. Do you think this is a problem with GetTickCount or the Settimer?
If you put 20ms as your interval you get 55ms exactly
Cheers
[Edited by Rick H on 06-21-2000 at 11:12 AM]
There was a debate about this awhile ago. The QueryPerformanceCounter is the most accurate one. 1 microsecond.
Yeah but that depends on the machine, i tested out the multimedia timer, that raised an event each millisecond, but it crashed as soon as you started to use your keyboard or mouse...
So I guess GetTickCount is the most stable one.
I don't think there's particulary stable or unstable api functions since they all work fine but what i meant was stable events raised by timers.