Link to home
Start Free TrialLog in
Avatar of Basicfarmer
BasicfarmerFlag for United States of America

asked on

Using Implements for a non blocking CCRP Timer

Experts, I am using Implements to use a non blocking ccrp timer. I need to declare the implements twice because i want to use two timers. Below is the code for one timer. But i do not know how to use implements to get two timer events.

Please let me know what i can do to get two timers running.

Implements ICcrpTimerNotify
Private receiveTimer As ccrpTimer

Private Sub Form_Load()

    Set receiveTimer = New ccrpTimer
    Set receiveTimer.Notify = Me
    
    receiveTimer.EventType = TimerPeriodic
    receiveTimer.Interval = 20
    receiveTimer.Stats.Frequency = 10
    
End Sub

Private sub ICcrpTimerNotify_Timer(Milliseconds as Long)

	'Do Timer stuff

End Sub

Open in new window

SOLUTION
Avatar of Mike Tomlinson
Mike Tomlinson
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Basicfarmer

ASKER

I have seen those pages and i have the CCRP Timer projects as examples. I can run a single timer. I see how the array example works but it not really multiple independent counters.

I tried to put this in a class and then raise an event thinking that way i could have two independent non blocking timers. But i cannot get it to work. I think it has something to do with Set receiveTmr.Notify = Me because it is in a class. Any ideas?

Implements ICcrpTimerNotify
Private receiveTmr As ccrpTimer

Public Event onTimer(Milliseconds As Long)

Private Sub Class_Initialize()
   
   Set receiveTmr = New ccrpTimer
   Set receiveTmr.Notify = Me
   
   receiveTmr.EventType = TimerPeriodic
   receiveTmr.Interval = 20
   receiveTmr.Stats.Frequency = 10

End Sub

Private Sub ICcrpTimerNotify_Timer(ByVal Milliseconds As Long)

    RaiseEvent onTimer(Milliseconds)

End Sub

Public Sub startTmr()

    receiveTmr.Enabled = True

End Sub

Public Sub stopTmr()

    receiveTmr.Enabled = False

End Sub

Open in new window

Thanks guys, even though i had seen those examples before i didnt really understand them. The suggestion to create another class got me pointed in the right direction.