Star-Dust Expert Licensed User Longtime User May 20, 2017 #1 Is it possible to use sleep commands with B4A 6.5? I saw following a @Erel thread that used this code to intercept errors in the servicer Starter (Application_Error) Code: Copy Dim jo As JavaObject Dim l As Long = 500 jo.InitializeStatic("java.lang.Thread").RunMethod("sleep", Array(l)) Does it correspond to B4A 7 sleep? Last edited: May 20, 2017
Is it possible to use sleep commands with B4A 6.5? I saw following a @Erel thread that used this code to intercept errors in the servicer Starter (Application_Error) Code: Copy Dim jo As JavaObject Dim l As Long = 500 jo.InitializeStatic("java.lang.Thread").RunMethod("sleep", Array(l)) Does it correspond to B4A 7 sleep?
DonManfred Expert Licensed User Longtime User May 20, 2017 #2 Star-Dust said: Is it possible to use wait and sleep commands with B4A 6.5? Click to expand... No. Upvote 0
Star-Dust Expert Licensed User Longtime User May 20, 2017 #3 Short but eloquent answer Thank's Upvote 0
Erel B4X founder Staff member Licensed User Longtime User May 21, 2017 #4 java.lang.Thread.sleep = Pauses the current thread for x milliseconds. New Sleep keyword = Saves the current sub state and returns. The sub will be resumed after x milliseconds. Upvote 0
java.lang.Thread.sleep = Pauses the current thread for x milliseconds. New Sleep keyword = Saves the current sub state and returns. The sub will be resumed after x milliseconds.
Star-Dust Expert Licensed User Longtime User May 21, 2017 #5 Many thanks, now I understand the difference. To create pauses, I could use java.lang.Thread.sleep instead of DoEvents in B4A 6.5 so I can be compatible with B4A 7 (where DoEvents is deprecated)? Upvote 0
Many thanks, now I understand the difference. To create pauses, I could use java.lang.Thread.sleep instead of DoEvents in B4A 6.5 so I can be compatible with B4A 7 (where DoEvents is deprecated)?
DonManfred Expert Licensed User Longtime User May 21, 2017 #6 DoEvents is still there (in V7) but it creates a warning now Upvote 0
LucaMs Expert Licensed User Longtime User May 21, 2017 #7 Sleep (the "original one") and DoEvents are not the same thing, completely different. You should use the deprecated DoEvents inside a loop to allow the refresh of the GUI. Upvote 0
Sleep (the "original one") and DoEvents are not the same thing, completely different. You should use the deprecated DoEvents inside a loop to allow the refresh of the GUI.
Star-Dust Expert Licensed User Longtime User May 21, 2017 #8 I know I'm not the same. In my code use DoEvents to create pauses (Type Delay (500)). I would avoid DoEvents because it was deprecated in version 7, so the code could be used by both versions. So java.lang.Thread.sleep could do my job Upvote 0
I know I'm not the same. In my code use DoEvents to create pauses (Type Delay (500)). I would avoid DoEvents because it was deprecated in version 7, so the code could be used by both versions. So java.lang.Thread.sleep could do my job
LucaMs Expert Licensed User Longtime User May 21, 2017 #9 Star-Dust said: I would avoid DoEvents because it was deprecated in version 7 Click to expand... It is deprecated (by Erel) from version 0.00 , not now only. The pauses you created are loops, right? And inside them you use DoEvents. java.lang.Thread.sleep does not allow you to use DoEvents, it is a single line of code. Upvote 0
Star-Dust said: I would avoid DoEvents because it was deprecated in version 7 Click to expand... It is deprecated (by Erel) from version 0.00 , not now only. The pauses you created are loops, right? And inside them you use DoEvents. java.lang.Thread.sleep does not allow you to use DoEvents, it is a single line of code.
Star-Dust Expert Licensed User Longtime User May 21, 2017 #10 Reading the posts of @Erel where it explains the resume sub, I understand the commands of Sleep and Wait for version 7. Before I knew their functions well. Certainly for me that I started to use in Turbo Pascal a concept is a bit difficult to digest Upvote 0
Reading the posts of @Erel where it explains the resume sub, I understand the commands of Sleep and Wait for version 7. Before I knew their functions well. Certainly for me that I started to use in Turbo Pascal a concept is a bit difficult to digest
Star-Dust Expert Licensed User Longtime User May 21, 2017 #11 I wanted to replace this Code: Copy Sub Delay(Time as int) Dim Now as Long = DateTime.Now while Datetime.Now<=Now+Time DoEvents Loop End Sub With Code: Copy Sub Delay(Time as Long) Dim jo As JavaObject jo.InitializeStatic("java.lang.Thread").RunMethod("sleep", Array(Time)) End Sub Last edited: May 21, 2017 Upvote 0
I wanted to replace this Code: Copy Sub Delay(Time as int) Dim Now as Long = DateTime.Now while Datetime.Now<=Now+Time DoEvents Loop End Sub With Code: Copy Sub Delay(Time as Long) Dim jo As JavaObject jo.InitializeStatic("java.lang.Thread").RunMethod("sleep", Array(Time)) End Sub
Erel B4X founder Staff member Licensed User Longtime User May 21, 2017 #12 What are you using this Delay for? You can probably switch to CallSubPlus. This is a better solution. Upvote 0
What are you using this Delay for? You can probably switch to CallSubPlus. This is a better solution.
Star-Dust Expert Licensed User Longtime User May 21, 2017 #13 Erel said: What are you using this Delay for? You can probably switch to CallSubPlus. This is a better solution. Click to expand... Ok, Thank's. Try it Upvote 0
Erel said: What are you using this Delay for? You can probably switch to CallSubPlus. This is a better solution. Click to expand... Ok, Thank's. Try it
Star-Dust Expert Licensed User Longtime User May 22, 2017 #14 Sorry again, probably is a stupid question, but I need to understand it well. Can not get a similar result with Threading Library? https://www.b4x.com/android/help/threading.html#lock_waitfor Example: https://www.b4x.com/android/forum/threads/threading-library.6775/#content Last edited: May 22, 2017 Upvote 0
Sorry again, probably is a stupid question, but I need to understand it well. Can not get a similar result with Threading Library? https://www.b4x.com/android/help/threading.html#lock_waitfor Example: https://www.b4x.com/android/forum/threads/threading-library.6775/#content
Erel B4X founder Staff member Licensed User Longtime User May 23, 2017 #15 Star-Dust said: Can not get a similar result with Threading Library? Click to expand... No. Resumable subs don't use any background threads. Last edited: May 23, 2017 Upvote 0
Star-Dust said: Can not get a similar result with Threading Library? Click to expand... No. Resumable subs don't use any background threads.
Star-Dust Expert Licensed User Longtime User May 23, 2017 #16 Erel said: No. Resumable subs doesn't use any background threads. Click to expand... Still thanks and sorry the many questions Upvote 0
Erel said: No. Resumable subs doesn't use any background threads. Click to expand... Still thanks and sorry the many questions