Solved

Using Implements for a non blocking CCRP Timer

Posted on 2013-11-11
4
470 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
ID: 39640715
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
ID: 39640938
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
ID: 39642292
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
ID: 39642836
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Use closed file on desktop in vba 6 67
Write data from SQL to CSV file - position 1 53
Convert VB6 MSXML2.ServerXMLHTTP process to C# 2 42
Visual Studio 2005 text editor 10 35
There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
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…
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…

896 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

13 Experts available now in Live!

Get 1:1 Help Now