Solved

Alternatives to make a keep alive timer or decay timer

Posted on 2003-12-08
20
620 Views
Last Modified: 2007-12-19
Hello. I would like to find an alternative to the following code to make a keep alive timer or decay timer that is more efficient and faster when running in VB and does not slow the program down. The code wa meant to prevent the timers from triggering as events keep firing or as individual conditions are satisfied.

    Timer1.Enabled = False ' reset/kill timer
    Timer1.Enabled = True ' keep timer alive so it does not decay

The fastest possible alternative I could think of is to use a timer control (like in assembly) that would increment a counter and fire once the interval has expired. All I would have to do was reset the counter variable back to zero and the timer would just keep counting. That was very fast because the timer never had to stop and restart. The timer itself did not waste resources because it was a hardware timer. Not sure how to incorporate this feature into vb efficiently without a lot of cluttered code all over the place.

An example of its use is shown below. It is oversimplified to what the current application is trying to accomplish.

Private Sub Form_Load
    Timer1.Enabled = False: Timer1.Interval = 100
    Timer2.Enabled = False: Timer2.Interval = 300
    Timer3.Enabled = False: Timer3.Interval = 1000
End Sub

Private Sub Event1(ByVal a As Integer, ByVal b As Integer)
    Static t1 As Long ': t1 = 0 initially, and ByRef for next iteration of event
    Dim var2 As Integer: var2 = 56 ' as fast as possible
    If t1 = 0 Or t1 + var2 > CLng(Timer() * 1000&) Then ' so not keep alive every single interation
        Timer1.Enabled = False ' reset/kill timer
        Timer1.Enabled = True ' keep timer alive so it does not decay
        t1 = CLng(Timer() * 1000&) ' backup current value
    Endif
    If a = 1 Then
        Timer2.Enabled = False ' reset/kill timer
        Timer2.Enabled = True ' keep timer alive so it does not decay
    End If
    If b = 2 Then
        Timer3.Enabled = False ' reset/kill timer
        Timer3.Enabled = True ' keep timer alive so it does not decay
    End If
End Sub

Private Sub Timer1_Timer()
    Timer1.Enabled = False ' not needed anymore
    Debug.Print "Timer1 Triggered"
End Sub
Private Sub Timer2_Timer()
    Timer2.Enabled = False ' not needed anymore
    Debug.Print "Timer2 Triggered"
End Sub
Private Sub Timer3_Timer()
    Timer3.Enabled = False ' not needed anymore
    Debug.Print "Timer3 Triggered"
End Sub

The dilemma is that accessing, killing and restarting the timer control all the time slows down the whole program. The related API timeSetEvent() and timeKillEvent() of course have also slowed it down when I used them. I currently have a real time application with the event being fired more than 300 times a second. The timers also have to wait the appropriate amount of time after the event is fired or conditions are satisfied and each is independent of the other.

I know timers in windows are asynchronous and a discussion on that has not helped speed up the keep alive process. I know vb timers are accurate only up to the nearest 55, 56 msec, or 1/18 sec but knowing that has not helped speed up the keep alive process. I know multimedia timers are more accurate but they has not helped speed up the keep alive process. I know that increasing thread priority may make timers more accurate but that has not helped speed up the keep alive process.

From benchmark testing on a 400MHz Pentium III in Windows 2000, when changing one timer enabled property from true to false to true:
- the code is the same exact speed while debugging, while in an unoptimized exe or while in an optimized exe
- the code is 10 times slower than manipulating a property of most controls on a form while debugging
- the code is 100 times slower than manipulating a property of most controls on a form while in an exe
- the code is 100 times slower than manipulating an integer variable while debugging
- the code is 1000 times slower than manipulating an integer variable in an exe
- overall restarting the timer is very inefficient and is the weekest link I can not seem to speed up in my code.

Please do not suggest these alternatives:

1. Running in an unoptimized or optimized exe did not speed it up.

2. I used an activex control written in VC to handle timers but that was not beneficial either because accessing and manipulating the activex through ole was slow in itself. And getting the results from the activex required another event to be fired which was slow too. And a fast timer in VC wasted resources too.

3. I already tried to use a fourth vb timer to keep firing every 56 msec and check the status of all other timers by polling and keep them alive. But it was still slow for my program and not efficient. Changing it to a multimedia timer was not beneficial and just introduced other problems to be avoided like wasting resources and slowing down, crashing program when stepping through debugging, crashing program if not kill timer when debugging, etc. Centralizing the conditions to fire a timer is not that great either making the program less modular.

Public var1 As Integer
Private Sub Form_Load
    var1 = 0: Timer1.Enabled = False: Timer1.Interval = 100
    Timer4.Enabled = True: Timer2.Interval = 56
End Sub
Private Sub Event1(ByVal a As Integer, ByVal b As Integer)
    var1 = 1
End Sub
Private Sub Timer1_Timer()
    Timer1.Enabled = False ' not needed anymore
    Debug.Print "Timer1 Triggered"
End Sub
Private Sub Timer4_Timer()
    If var1 = 1 Then
        Timer1.Enabled = False ' reset/kill timer
        Timer1.Enabled = True ' keep timer alive so it does not decay
        var1 = 0
    End If
End Sub

4. Alternative to step 2, but very clumsy and ugly. Also wastes resources while timer is firing so fast all the time and polling which is inefficient.

Public var1 As Integer
Private Sub Form_Load
    Timer4.Enabled = True: Timer4.Interval = 56
End Sub
Private Sub Event1(ByVal a As Integer, ByVal b As Integer)
    var1 = CLng(Timer() * 1000&)
End Sub
Private Sub Timer4_Timer()
    Dim var2 As Integer: var2 = 300 ' similar to Timer2.Interval = 300
    If var1 + var2 > CLng(Timer() * 1000&) Then ' ignoring limitation at midnight
        Call Timer2_Common()
        var1 = 0
    End If
End Sub
Private Sub Timer2_Common()
    Debug.Print "Timer2 Triggered"
End Sub

Thanks.
Joseph
0
Comment
Question by:jtbalogh
  • 14
  • 2
  • 2
  • +1
20 Comments
 
LVL 3

Expert Comment

by:TimW1
ID: 9902683
Here is some code to use an API Timer.  It may be more efficient than VB as the triggering event is comming directly from the Op system.  Create a new class (cTimer or whatever).  Paste it in and add the TimerSub to a module.  
** Note:  If you are debugging in the IDE, it is advisable to never click STOP when the timer is running.  Make sure you stop the timer first.

'Class: cTimer
'Purpose:  Use this similar to VB Timer control.  Must add the TimerSub to a Module.
'---- Add this sub to a Module - it will be the Timer Event -----
'Public Sub TimerSub(ByVal lHwnd As Long, _
'ByVal lMsg As Long, ByVal mlTimerID As Long, _
'ByVal lTime As Long)
'    'This sub must be in a module.
'    'Do Something Here
'End Sub
'----------------------------------------------------------------
Option Explicit
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
Private mlTimerID As Long
Private mlInterval As Long
Public Property Get Interval() As Long
    Interval = mlInterval
End Property
Public Property Let Interval(vdata As Long)
    'Pass milliseconds - 1000 = 1 second
    mlInterval = vdata
End Property

Private Sub StartTimer(lAddressOfFunction As Long)
    mlTimerID = SetTimer(0, 0, mlInterval, lAddressOfFunction)
End Sub
Private Function StopTimer() As Long
'must pass the TimerId returned by SetTimer
StopTimer = KillTimer(0, mlTimerID)
mlTimerID = 0
End Function
Public Property Let Enabled(vdata As Boolean)
    If Me.Enabled = vdata Then
        Exit Property
    End If
    If vdata = True Then
        StartTimer AddressOf TimerSub
    Else
        StopTimer
    End If
End Property
Public Property Get Enabled() As Boolean
    Enabled = mlTimerID <> 0
End Property
Private Sub Class_Terminate()
    Enabled = False
End Sub
0
 
LVL 1

Expert Comment

by:jimmurphy030700
ID: 9904244
Why can't you use the VB Timer Function instead of the Control?  Just place it where you want the timed delay, or make it a function and call it when you need it.

Dim StartTime as Single
Dim PauseTime as Single

  ' Set delay duration...
    PauseTime = 5
  ' Set start time...
    StartTime = Timer
    Do While Timer < StartTime + PauseTime
       '  Check program conditions and exit if true...
        If conditions True then Exit Do
       '  Otherwise yield to other processes and loop...
        DoEvents
    Loop
    ....

0
 
LVL 2

Author Comment

by:jtbalogh
ID: 9909110
-----------------------------------------------
Sorry TimW1, you may have misunderstood me. We still have the problem of killing & enabling an API timer which is not faster then a vb timer. Gaining accuracy with multimedia timers does not resolve the issue and I do not need the limitations, you also noticed, "never click STOP". The original problem lies in the boolean condition you attempted to show. It should have been as shown below.
    If vdata = True Then
        StopTimer
        StartTimer AddressOf TimerSub
    End If

-----------------------------------------------
Sorry jimmurphy, you may have misunderstood me. Your loop does not address the issue. It is similar to my suggestion 4 where I used a timer for polling to check conditions repeatedly, while you used a fast inefficient loop for polling. Meanwhile, your loop should never exit otherwise we have to worry about triggering that loop too somehow to start. Doevents makes it more inefficient taking up 100% cpu and has lots of limitations that doevents is known for (like it is very slow and can not guarentee it returns if message deadlock occurs). Using API sleep(10) in the loop helps reduce cpu usage but it is still wasting resources running all the time. The fast loop also holds up the main thread the vb application is running in since vb is a single threaded architecture.
0
 
LVL 2

Author Comment

by:jtbalogh
ID: 9909163
TimW1, now I see where you were going with this but all you did was replace a vb timer with an API timer and we are back to the same problem.

Public cTimer1 As New cTimer
Public cTimer2 As New cTimer
Public cTimer3 As New cTimer

Private Sub Form_Load
    Set cTimer1 = New cTimer
    Set cTimer2 = New cTimer
    Set cTimer3 = New cTimer
End Sub

Private Sub Event1(ByVal a As Integer, ByVal b As Integer)
    cTimer1.Enabled = False ' reset/kill timer
    cTimer1.Enabled = True ' keep timer alive so it does not decay
    If a = 1 Then
        cTimer2.Enabled = False ' reset/kill timer
        cTimer2.Enabled = True ' keep timer alive so it does not decay
    End If
    If b = 2 Then
        cTimer3.Enabled = False ' reset/kill timer
        cTimer3.Enabled = True ' keep timer alive so it does not decay
    End If
End Sub

The time it takes to set any timer to false and back to true is what is slow when the event is firing over 200 times a second. That is where the alternative was trying to be implemented.
0
 
LVL 2

Author Comment

by:jtbalogh
ID: 9909411
The theoretically possibilities as alternatives but make the code less readible and more cluttered are shown below. I need an easier way. Please do not suggest API timers or activex components because they are slow in different ways and what I gain with one feature, I loose with other features.

To replace the following two lines of code:

    Private Sub Event1(ByVal a As Integer, ByVal b As Integer)
        Timer1.Enabled = False ' reset/kill timer
        Timer1.Enabled = True ' keep timer alive so it does not decay
    End Sub

----------------------------------
1. Use the complicated code,

Public nTimer1 As Long

Private Sub Event1(ByVal a As Integer, ByVal b As Integer)
    nTimer1 = CLng(Timer() * 1000&) ' rest counter so timer does not really trigger
    Timer1.Enabled = True ' turn on if not already

    ' The following code would be replaced by the routine above
    ' and related routines
    'Timer1.Enabled = False ' reset/kill timer
    'Timer1.Enabled = True ' keep timer alive so it does not decay
End Sub

Private Sub Timer1_Timer()
    If nTimer1 + Timer1.Interval > CLng(Timer() * 1000&) Then
        ' Triggered before it was time
        Timer1.Enabled = False ' reset/kill timer to set new interval
        ' Wait a little bit more for full interval
        Timer1.Interval = Timer1.Interval - (CLng(Timer() * 1000&) - nTimer1)
        Timer1.Enabled = True ' keep timer alive so it does not decay
        Exit Sub
    End If

    Timer1.Enabled = False ' not needed anymore
    Debug.Print "Timer1 Triggered"
End Sub

----------------------------------
2. Or, use the complicated code,

Public isTimer1 As Boolean
Public mTimer1 As Integer

Private Sub Event1(ByVal a As Integer, ByVal b As Integer)
    ' Keep timer running so it does not trigger yet
    ' by resetting counter the timer is using to determine when to trigger.
    mTimer1 = 0
    If isTimer1 = False Then
        ' Start FastTimer for the first time
        FastTimer.Enabled = True ' keep timer alive so it does not decay
        isTimer1 = True
    Endif

    ' The following code would be replaced by the routine above.
    'Timer1.Enabled = False ' reset/kill timer
    'Timer1.Enabled = True ' keep timer alive so it does not decay
End Sub

Private Sub Timer1_Timer()
    ' Once this triggers it means the event has not fired and there was
    ' enough time for mTimer1 to increment until mTimer1 > Timer1.Interval
    Debug.Print "Timer1 Triggered"
End Sub

Private Sub FastTimer_Timer()
' Something that can increment the counter.
' I wish this timer did not have to be created in the first place.
' - not too modular, especially when more than one timer will be used in the app
' - wastes resources triggering all the time
If isTimer1 = True Then
    mTimer1 = mTimer1 + FastTimer.Interval
    If mTimer1 > Timer1.Interval Then
        isTimer1 = False
        mTimer1 = 0
        Call form1.Timer1_Timer() ' triggering timer indirectly from here not very modular
    End If
End If
'FastTimer.Enabled = False ' knowing when to turn off gets more complicated when multiple timers will be used in the app
End Sub

Any ideas to make this more simple? I had to convert two rows of program code into all this cluttered stuff. I wish there was a better way.
0
 
LVL 3

Expert Comment

by:TimW1
ID: 9909683
Ok, I am still trying to understand this but here goes:

You need an efficient way to pause/stop a timer, using minimal timeslices etc.
I am assuming that the timer intervals stay the same and all you need to do is stop and start them at appropriate times.
There will have to be at least 1 call per timer to disable or pause it.

I have put an api version becuase it will be more flexible.
If you don't kill the timer, just change the time interval then the timer would not need to be unloaded etc and there would be fewer calls.
I have experiemented with setting the interval to 0, -1 etc and it just made it fire instantly.  Perhaps the interval could be raised to the largest possible timeout.  I'm guessing here (i couldn't find it at msdn) but the timeout will probably be larger than the VB control.  Hopefully you could set a large timeout to effectively Pause the control.

Try using the api code I posted and add a Pause sub that simply re calls:
mlTimerID = SetTimer(0, 0, MAX_LONG_VALUE, mlAddressofFunction)
Add a continue sub:
mlTimerID = SetTimer(0, 0, mlInterval, mlAddressofFunction)

Also check out this page:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/WinUI/WindowsUserInterface/Windowing/Timers/AboutTimers.asp
Have a look at the High Resolution timer.  I'm not sure if it will suit, it looks more like a counter to me.

There is also a different type of API timer you can use (WaitableTimers)
http://support.microsoft.com/default.aspx?scid=http://support.microsoft.com:80/support/kb/articles/Q231/2/98.ASP&NoWebContent=1
Perticuly the "Periodic Timer".  The functionality may achieve the same result but it may be more efficient or you may be able to set a time out of 0 or -1 perhaps.  I haven't used these so I can't comment on how well they work sorry.






0
 
LVL 2

Author Comment

by:jtbalogh
ID: 9928729
Are you talking about changing the interval while the timer is already enabled and waiting to be triggered?
0
 
LVL 2

Author Comment

by:jtbalogh
ID: 9928744
Again, to remind you that I am not pausing the control and please do not formulate something to this effect. All threads in the application are continuously running and nothing is paused. You were on the rght track when you mentioned, "pause/stop a timer, using minimal timeslices". Thanks.
0
 
LVL 2

Author Comment

by:jtbalogh
ID: 9928908
The links you mentioned I already know about but it is nice to know you use those advanced features too in your apps. They are currently for different features not related to my problem. I currently only use the QueryPerformanceFrequency() to track the speed of code. It is not for triggering a timer. I currently use waitable timer to replace my sleep function in VB due to the benefits. It still pauses program. Unfortunately, none of those help my problem.

I see where you were going with trying to get interval to 0 or -1, but that is not the speed I wanted to improve. Pausing less than a milisecond was not the goal.

Rewording: "running timer stop then timer start as fast as possible using minimal timeslices to keep the timer from triggering and expiring with the original interval. Timer should now keep continuing and trigger when the new interval expires. The interval of the timer is always 500 miliseconds for example and that does not need to be fast."

Hope that helps.
0
What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
LVL 2

Author Comment

by:jtbalogh
ID: 9928985
Are you talking about changing the interval while the timer is already enabled and waiting to be triggered? I dont think so but that would have been one solution if it worked - if only I could keep increasing the interval or reset it somehow so the timer never triggers in the first place when it was supposed to.

That feature you mentioned,

"If you don't kill the timer, just change the time interval then the timer would not need to be unloaded etc and there would be fewer calls."

I already know about that and usually only worked for me when the timer has already triggered and before exitting the timer function. I did not want the timer to trigger at all yet. The feature was only nice to make the interval smaller temporarily in case previous iterations of the timer took longer than expected due to delays in the application.
0
 
LVL 2

Author Comment

by:jtbalogh
ID: 9929460
Another way of looking at problem and need alternative to speed up command1. Command1 is 2000 times slower than command2 in an optimized exe:

Private Sub Command1_Click()
Dim i As Integer
Timer1.Interval = 500
For i = 1 To 32000 ' large to notice visually, but usually only 1000 anyway
Timer1.Enabled = False
Timer1.Enabled = True
Next i
' once timers is not reset anymore, it triggers after interval expires
End Sub

Private Sub Command2_Click()
Dim i As Integer, T as boolean
For i = 1 To 32000
T = False
T = True
Next i
' only for comparing speed of loop
End Sub

Hope that helps show what I am looking for. Thanks.
0
 
LVL 2

Author Comment

by:jtbalogh
ID: 9929469
Increase points to 500. Does anyone have a clever and simple way to solve the problem?
0
 
LVL 2

Author Comment

by:jtbalogh
ID: 9940075
Anyone?

The example on Dec 12 was not the best comparison. I am sorry. Expected enabling a timer be as fast as saving to a boolean variable was foolish. I just wanted to show that it was a waste of time killing and enabling the timer all the time. I do not know how many loops Command 1 will do, and do not know how often Command1 would be executed. But I do know the timer may be reenabled more than 500 times a second which slows down the program. As long as the Timer1 trigger is postponed, that was the goal. Thanks.
0
 
LVL 1

Expert Comment

by:jimmurphy030700
ID: 9942690
Please clarify, Joseph...is speed your ultimate goal, or is minimization of resources, or both?  On my machine, the loop I mentioned earlier ran about 600K iterations/sec and only fired the timer function once, compared to 40K iterations/sec for the timer control solution.  But as you noted, the loop process is a resource hog.  It just depends on your ultimate goal and specific use.  Since there are no acceptable solutions to this point, maybe it would help if you briefly re-posted the question, and provided a single, specific code sample that you wanted to improve.  I think possibly this thread has gotten too big and convoluted to attract any new attention.  --Jim
0
 
LVL 2

Author Comment

by:jtbalogh
ID: 9966854
Thanks jimmurphy for your suggestion. My question may been more advanced then I thought. You were on the right track that the loop is faster without a timer control solution. I wish your solution could have helped, but your example is only like the API function Sleep(5) with the variation of being able to check conditions while waiting. It did not help to replace killing and starting a timer because it did not trigger anything to happen, and there is no indication how it would first start running either.

Since you could not help me, perhaps I can help you for the kindness to assist me. Just an observation, if you do not mind me pointing out how to improve your procedure:

:)

1. The loop of 600K/sec is nice but is overkill for the limitation of the timer function. The timer function may not be updating for 10 msec anyway so conditions using a pause time of 5 msec is not reliable. The Timer function is known to have only an accuracy of +/- 5msec in Win NT and Windows 2000. It is accurate up to +/- 1msec in Win95 and Win98 though. (As per microsoft reference manual). Solution: pause time = 50 minimum, loop with Sleep(1) and with DoEvents. Now resources are not hogged as much, and the accuracy of the timer can taken into account, and the loop may still poll conditions. Of course now the loop is taking a 1 msec timeslice from the entire program to execute but polling techniques can not hope for better to achieve.

2. I have seen the Timer function being executed every iteration when the loop had to evaluate the expression, but that is still fast and not usually a concern.

Observations can be seen in this example running on Petium III with Windows 2000:

Private Sub Command1_Click()
    Dim i As Integer
    Dim a(2000) As Long ' alternative
    a(1) = 0
    For i = 1 To UBound(a, 1)
        a(i) = CLng(Timer() * 1000&) ' in milliseconds
        DoEvents
    Next i
    For i = 1 To UBound(a, 1)
        Debug.Print Trim(Str(a(i))) ' outside of loop since it is a slow command
        ' results may skip in 10 msec increments (+5 to -5)
        ' and not changing most of the time.
    Next i
End Sub
0
 
LVL 2

Author Comment

by:jtbalogh
ID: 9966867
-------------------------------------------
Restating the Problem:

The specific code (as shown in the first statement in the question) is to avoid doing the following two statements at every iteration of a loop so that Timer1 can be kept from firing until the process is finished or idle. The speed is not how fast I can make it loop but in how keep Timer1 alive without resetting it all the time.

Timer1.Enabled = False ' reset/kill vb timer
Timer1.Enabled = True ' keep timer alive so it does not decay

Used in this context:

    Private Sub Main()
        Timer1.Interval = 500 ' already set long enough to wait for idle
        Timer1.Enabled = False ' not enabled yet
        Timer2.Interval = 3000 ' already set long enough to wait for idle
        Timer2.Enabled = False ' not enabled yet
        objectActiveX.Interval = 33 ' fast multimedia timer that might trigger event
        objectActiveX.Enabled = True ' ready to let a component process
    End Sub

    ' In an active-x control, a multimedia timer is used to fire the event somewhere between zero and a thousand times a second. It is unknown when it will fire or how often which is why a second vb timer, Timer1, is used to monitor the activity and only trigger when the object is not firing the event anymore. There is a loop in this context but not the conventional for-next or do-loop. The loop is generated by multimedia timers triggering periodicially. When the timers are idle at each iteration, resources are released and available. No need to use DoEvents.

    Private Sub Event1(ByVal a As Integer, ByVal b As Integer)
        ' Run a bunch of code, may be slow or fast, who knows.
        Timer1.Enabled = False ' reset/kill timer
        Timer1.Enabled = True ' keep timer alive so it does not decay
        ' Run more code.
        Timer2.Enabled = False ' reset/kill timer
        Timer2.Enabled = True ' keep timer alive so it does not decay
        ' (Unknown how many times event is fired per second since not know
        ' how many times event is fired per multimedia timer interval.)
    End Sub

-------------------------------------------
Possible Solution but not preferred:

Fastest equivalent but is very awkward especially if more than one timer is used in the application (example restated based on previous examples of my comments):

    Public Timer1Time As Long
    Public Timer2Time As Long

    Private Sub Main()
        Timer1Time = 0
        Timer1.Interval = 500 ' already set long enough to wait for idle
        Timer1.Enabled = False ' already set disabled since have to run manually
        Timer2Time = 0
        Timer2.Interval = 3000 ' already set long enough to wait for idle
        Timer2.Enabled = False ' already set disabled since have to run manually
        TimerCommon.Interval = 55 ' already set fast enough
        TimerCommon.Enabled = True ' poll to check conditions (a waste of resources, oh well)
    End Sub

    Private Sub EquivalentEvent1(ByVal a As Integer, ByVal b As Integer)
        ' Run a bunch of code, may be slow or fast, who knows.
        Timer1Time = CLng(Timer() * 1000&) ' in msec (accuracy +/-5 msec in Win NT and 2K)
        ' Run more code.
        Timer2Time = Timer1Time
        ' Reset by shifting start time to keep alive and not trigger timer yet.
        ' Save to public variable so conditions can evaluate later.
    End Sub

    Private Sub EquivalentTimerCommon_Timer()
        ' Periodically poll faster than any timers used in event, like Timer1.Interval.
        If CLng(Timer() * 1000&) > Timer1Time + Timer1.Interval Then
            ' Event now seems to be idle since time is not being reset.
            Call Timer1_Timer() ' run manually
        End If
        If CLng(Timer() * 1000&) > Timer2Time + Timer2.Interval Then
            ' Event now seems to be idle since time is not being reset.
            Call Timer2_Timer() ' run manually
        End If
    End Sub

There is no need to use DoEvents in any examples, and the fastest loop (which is the event) has nothing to do with the intervals Timer1 and Timer2 use to keep alive. Hope that clears it up.
0
 
LVL 2

Author Comment

by:jtbalogh
ID: 10003353
Any experts have an answer so I can relieve myself of the points and go home happy ?
:)
0
 
LVL 2

Author Comment

by:jtbalogh
ID: 10018935
JTBalogh last comment on 12/18/2003 12:01PM PST would be the solution unless someone has a better alternative. Thanks.
0
 

Accepted Solution

by:
PashaMod earned 0 total points
ID: 10198382
PAQed, with points refunded (500)

PashaMod
Community Support Moderator
0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now