Alberto Michelis Well-Known Member Licensed User Longtime User Jun 13, 2015 #1 Hi, I have a service with a timer of 10 seconds. The timer fires a routine which reads some data from the web I need to tell the service to read that data "now" no mater what the timer is set on. Any Idea? Thanks
Hi, I have a service with a timer of 10 seconds. The timer fires a routine which reads some data from the web I need to tell the service to read that data "now" no mater what the timer is set on. Any Idea? Thanks
NJDude Expert Licensed User Longtime User Jun 13, 2015 #2 Just call the _Tick sub when you need it. Upvote 0
Alberto Michelis Well-Known Member Licensed User Longtime User Jun 13, 2015 #3 and what if the timer calls it at the sema time? Upvote 0
Alberto Michelis Well-Known Member Licensed User Longtime User Jun 13, 2015 #4 and how do I call it from inside the same service? I can check a main variable in the service timer but haw does the timer know I need to call its own _tock sub? Upvote 0
and how do I call it from inside the same service? I can check a main variable in the service timer but haw does the timer know I need to call its own _tock sub?
RandomCoder Well-Known Member Licensed User Longtime User Jun 14, 2015 #5 You can just call the sub like you would any other sub. But personally I think it's better to move all the code out of the tick event and into a new subroutine. Then you can call this sub from the tick event or from anywhere else in your code. It really makes no difference but I just like to have event driven subs fired by the events and not manually called in the code, in my opinion it makes the code easier to follow. Upvote 0
You can just call the sub like you would any other sub. But personally I think it's better to move all the code out of the tick event and into a new subroutine. Then you can call this sub from the tick event or from anywhere else in your code. It really makes no difference but I just like to have event driven subs fired by the events and not manually called in the code, in my opinion it makes the code easier to follow.
Beja Expert Licensed User Longtime User Jun 14, 2015 #6 Code: Copy Sub TimerBruteForce tmTimer.Enablled = False tmTimer.Enablled = True End Sub __________________________________________ Sub btnButton_Click TimerBruteForce End Sub Upvote 0
Code: Copy Sub TimerBruteForce tmTimer.Enablled = False tmTimer.Enablled = True End Sub __________________________________________ Sub btnButton_Click TimerBruteForce End Sub
Alberto Michelis Well-Known Member Licensed User Longtime User Jun 14, 2015 #7 The Sub I need to call is in a service which fires it with a timer. What happen if I call the service sub from another module "at the same time" as it was called by the service itself? Upvote 0
The Sub I need to call is in a service which fires it with a timer. What happen if I call the service sub from another module "at the same time" as it was called by the service itself?
RandomCoder Well-Known Member Licensed User Longtime User Jun 14, 2015 #8 It is still running on the main thread and so it can only occur one after the other. If your not wanting to repeat the process in the Tick event just use a Process Gloabl variable to set whether your function has been run or not. Upvote 0
It is still running on the main thread and so it can only occur one after the other. If your not wanting to repeat the process in the Tick event just use a Process Gloabl variable to set whether your function has been run or not.