No, you need to make a Timer subclass. This subclass should have a
property of type <reference-to-the-class-which-needs-the-timer>.
along with a setter method for it.
For example, if your class (the one that needs the timer) is called,
"MyClass", then
Class MyTimerSubclass
Protected Property fParent As MyClass
Public Sub Parent(Assigns o As MyClass)
fParent = o
End If
...
End Class
then, in your "MyClass", have a public method which will act as a
callback for the timer. Then...
Class MyClass
Protected Property fMyTimer As MyTimerSubclass
Public Sub MyClass()
// Constructor
fMyTimer = New MyTimerSubclass()
fMyTimer.Parent = Me
fMyTimer.Period = ??? // whatever time delay you want.
fMyTimer.Mode = 0 // turn it off until needed.
End Sub
Public Sub TimerCallback()
// Called through fMyTimer's .Parent property when the timer
times out.
...
End Sub
End Class
Now, go back to the code editor for MyTimerSubclass and put the
following in its Action() event.
Sub Action()
fParent.TimerCallback()
End Sub
and there you have it. Keep in mind that timers (even those not in a
window) won't fire unless the OS yields time (in the event loop) to
them!
If this is a problem, you may want to consider a Thread subclass
instead.
On Mar 17, 2007, at 8:50 PM, Eric Richards wrote:
> Hi -
>
> I'm wanting to know can you use a timer
> in a class like you would use a timer normaly ?
>
> That is, if I do this
> property -
> MyTimer as Timer (private)
>
> Can I use MyTimer in the class its self ?
> If so, how ?
>
> I could be wrong, but I have a feeling that it doesn't
> work that way.
>
> Thanks
>
> Eric
>
> Rb tripple 5
>
> _______________________________________________
> Unsubscribe or switch delivery mode:
> <http://www.realsoftware.com/support/listmanager/>
>
> Search the archives:
> <http://support.realsoftware.com/listarchives/lists.html>
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>
Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>