B4A Tutorial [B4X] Resumable subs that return values (ResumableSub) - Erel    Aug 25, 2020   (39 reactions) The steps required are:
1. Add As ResumableSub to the resumable sub signature.
2. Call Return with the value you like to return.
3. In the calling sub, call the resumable sub with Wait For (<sub here>) Complete (Result As <matching type>)
Notes & Tips
- If you don't need to return a value but sti B4A Tutorial [B4X] Resumable subs and the index pattern - Erel    Nov 24, 2019   (26 reactions) The "index pattern" is a pattern that you can see in many examples and libraries where resumable subs are used. It is a simple solution to avoid race conditions and unexpected states. The resumable subs code like all other standard B4X code, is executed by the main thread. Still, with resumable sub B4J Tutorial [B4X] Resumable Subs - Sleep / Wait For - Erel    Feb 22, 2018   (49 reactions) New video tutorial:
255570732
Resumable subs is a new feature added in B4J v5.50 / B4i v4.00 / B4A v7.00. It dramatically simplifies the handling of asynchronous tasks.
(This feature is a variant of stackless coroutines.)
The special feature of resumable subs is that they can be paused, without p B4J Tutorial [B4X] How Resumable Subs work - agraham    Jan 30, 2019   (27 reactions) Typically you might use the value of global variables to decide what needs to be done after the next event and call an appropriate Sub when an event occurs.
The Resumable Sub mechanism allows this "do, wait, then finish" to be conveniently expressed in a single Sub as sections of code separated by B4A Question is it possible to use two job in a single activity - Erel (first post)    Apr 08, 2018   (1 reaction) Not correct. Resumable subs is a very complicated compiler feature. It is not just an event handler. It allows your sub to resume at a specific point in the exact state it was before. See the resumable subs video tutorial for more information. B4J Code Snippet Resumable Subs (wait for / sleep) in server handlers - Erel    Feb 16, 2020   (15 reactions) The Handle sub cannot be a resumable sub itself.
Why?
- Wait For / Sleep must be called before the call to StartMessageLoop or they will never be executed.
- Wait For / Sleep code flow is equivalent to Return so if they appear before StartMessageLoop then the message loop will never be created and B4A Question How to avoid using "Wait For" - Erel (first post)    Dec 30, 2020   (2 reactions) Nope. It has nothing to do with Android. The resumable subs feature is a 100% B4X compiler feature. B4A Question Resumable Subs - order of execution - aeric (first post)    May 29, 2021   (3 reactions) 'Initializes the object. You can add parameters to this method if needed.
Public Sub Initialize
Download1 'Resumable Sub1
End Sub
Sub Download1
Wait For (GetIDs (ID1, user, psw)) Complete (result1 As List)
'code...
Download2 'Resumable Sub2
End Sub
Sub Download2
Wait For (GetID Italian lamentela sulla nuova versione - LucaMs (first post)    Sep 09, 2017   (1 reaction) https://www.b4x.com/android/forum/threads/b4x-resumable-subs-sleep-wait-for.78601/
Diceva:
Resumable subs is a new feature added in B4J v5.50 / B4i v4.00 / B4A v7.00. It dramatically simplifies the handling of asynchronous tasks.
(This feature is a variant of stackless coroutines.)
"Questa funzional B4J Question Resumable Subs with Java Inline Code? - Erel (first post)    May 28, 2017   (1 reaction) You cannot call Sleep or Wait For from inline code. Resumable subs is a compiler feature. The compiler converts the resumable subs code to a state machine.
You can raise regular events from the inline Java code (with ba.raiseEventFromUI) and use Wait For in your B4J code. Page: 1   2   3   4   5   6   7   Powered by ColBERT |