B4J Question Is there something like "Wait" or "Delay" for some milliseconds?

positrom2

Active Member
Licensed User
Longtime User
In communication with a µC I need to have some delay before sending a new request for transmitting data to the µC. In the µC dialect , there is a "Wait" statement as a delay before executing the next statement. How could I implement that in B4J?
 

derez

Expert
Licensed User
Longtime User
Two options:
1. Not recommended - a waste time loop
2. Recommended - a timer that is enabled at the start event and ticks after the delay period.
 
Upvote 0

positrom2

Active Member
Licensed User
Longtime User
1. Not recommended - a waste time loop
2. Recommended - a timer that is enabled at the start event and ticks after the delay period.
1: There is no hurry.
2: I know. But that needs to rewite the code and, (despite of 1), the timer always has to treat the (unknown) worst case. In many dialects we have delay instructions, so why not here?
 
Upvote 0

positrom2

Active Member
Licensed User
Longtime User
Thanks for the delay function. Actually, I used something like that in B4A while ago -but I forgot about it...
The "sleep" function looks a little difficult to implement but I will try also.
 
Upvote 0

jmon

Well-Known Member
Licensed User
Longtime User
The "sleep" function looks a little difficult to implement but I will try also.
Yes, I agree with you, I was just suggesting as an alternate method, but the one Erel recommanded is the best.
 
Upvote 0
Top