Solved

Using Implements for a non blocking CCRP Timer

Posted on 2013-11-11
4
459 Views
Last Modified: 2013-11-12
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

0
Comment
Question by:Basicfarmer
  • 2
4 Comments
 
LVL 85

Assisted Solution

by:Mike Tomlinson
Mike Tomlinson earned 250 total points
Comment Utility
Check out the example on how to use multiple timers:
http://vb.mvps.org/tools/ccrpTmr/docs/ccrpDemoObjArray.htm
0
 
LVL 10

Accepted Solution

by:
joriszwaenepoel earned 250 total points
Comment Utility
You cannot implement the same interface more than once in a single class.

I do not know these CCRP-interfaces, but if you need 2 timers, maybe you need to create 2 instances of the class? Or you need to implement another interface IccrpTimerNotifyEx for mulitple timers?

See
http://vb.mvps.org/tools/ccrpTmr/docs/ccrpMiscInterfaces.htm
0
 

Author Comment

by:Basicfarmer
Comment Utility
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

0
 

Author Closing Comment

by:Basicfarmer
Comment Utility
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.
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
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…

744 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

12 Experts available now in Live!

Get 1:1 Help Now