B4J Question Problem with Resumable Sub that recursively call itself. - max123    
May 7, 2024 is the MinifyAllFilesOnFolderAsync sub,
the sub should recursively minimize all JS and CSS files in the specified... are processed recursively and then the result return should return back to the calling sub (a Wait For in...
link:
Can I just use a global List without return it back from the ProcessFile and then from TraverseAsyn...
link: Here my last. I added TraverseFolders4.
The only difference is that it use a global List instead of...
link: @OliverA I want to use your TraverseFolder3 method in my library, but I've difficult to adapt my...
B4J Question Resumable subs with recursive File.ListFiles to update UI - walt61    
Jun 3, 2017Hi all,
I'm trying to get my head around this but have tried a number of things with Sleep and Wait For, all of which failed. I think it's the recursion that gets in my way but perhaps am... the folder currently being searched in a label. Without resumable subs, the UI of course isn't...
link: , but the recursion seemed to throw a spanner in the works.
@Erel : excellent idea, that will do...
link: The recursion does make it more complicate. Remember that Sleep causes the code flow to return so...
B4A Tutorial [B4X] Resumable subs that return values (ResumableSub) - Erel    
Aug 25, 2020   
(41 reactions)Remember that that a call to Sleep or Wait For in a resumable sub causes the code flow to return to....
Solution
Resumable subs can return a new type named ResumableSub. Other subs can use this value to...)
End Sub
Sub Sum(a As Int, b As Int) As ResumableSub
Sleep(100)
Log(a + b)
Return a + b
End... Button1_Click
Dim rs As ResumableSub = Sum(1, 2)
Wait For(rs) Complete (Result As Int)
Log... As ResumableSub to the resumable sub signature.
2. Call Return with the value you like to return.
3...
B4J Tutorial [B4X] Resumable Subs - Sleep / Wait For - Erel    
Feb 22, 2018   
(50 reactions)New video tutorial:
255570732
Resumable subs is a new feature added in B4J v5.50 / B4i v4.00... of stackless coroutines.)
The special feature of resumable subs is that they can be paused, without pausing the executing thread, and later be resumed.
The program doesn't wait for the resumable... or Wait For is a resumable subs. The IDE shows an indicator next to the sub declaration:
https://www...)
Sleep(1000)
Log(2)
The sub will be paused for 1000 milliseconds and then be resumed.
You can call...
B4A Code Snippet [B4X] CopyFolder / DeleteFolder / RecursiveList - Erel    
Oct 19, 2025   
(26 reactions)A recursive sub that copies a complete folder.
Private Sub CopyFolder(Source As String....
Recursively deletes a folder and its sub folders:
Sub DeleteFolder (folder As String)
For Each f...
link: Method to recursively list files in a folder was added to first post....
link: Moving it to a service will not change anything.
On Android 11, after some time without errors, co...
link: Hello,
I have used the "copyfolder" routine to copy large amounts of files and directorie...
B4J Code Snippet Resumable Subs (wait for / sleep) in server handlers - Erel    
Feb 16, 2020   
(15 reactions)Resumable subs can only work when there is a message queue.
By default, server handlers end when the Handle sub is completed. They do not create a message loop.
If you want to wait for an event then you need to call StartMessageLoop and later StopMessageLoop.
Example of handler that downloads a page and returns it as the response:
Sub Handle(req As ServletRequest, resp As ServletResponse...
j.Release
StopMessageLoop '<----
End Sub
The Handle sub cannot be a resumable sub...
B4A Library [B4X] [XUI] Scrolling Label - Erel    
Nov 3, 2021   
(26 reactions), you should add this code to Activity_Resume:
Sub Activity_Resume
For Each v As View In Activity.GetAllViewsRecursive
If v.Tag Is ScrollingLabel Then
Dim sl As ScrollingLabel = v.Tag...
B4A Question Array versus List - LucaMs (first post)    
May 4, 2018Is it normal that Sleep(0) breaks recursive routines?
As Erel would say: you should open a new thread for this question.
I think that you might have problems with "resumable commands" inside recursive routines = resumable recursive routines.
https://www.b4x.com/android/forum/pages/results/?query=resumable+recursive...
link: You can use Sleep(0) inside recursive subs however you need to understand how resumable subs work...
B4J Question OpenJFX 11 - Charles Nguru (first post)    
Dec 11, 2020Is there a reference "manual" for all the inbuilt libraries or is there a tutorial that just covers them?
The resumable and recursive subs tutorials are great and easy to understand including the very technical explanation done by agraham....
B4J Code Snippet Resumable subs in console/non-ui apps - Erel    
Jul 5, 2026   
(14 reactions)We want to create a small program that downloads something and quits.
First failed attempt:
'Will not work
Sub AppStart (Args() As String)
Dim job As HttpJob
job.Initialize("", Me)
job.Download("https://www.google.com")
Wait For (job) JobDone(job As HttpJob)
If job.Success Then
Log(job.GetString)
End If
job.Release
End Sub
Failure reason: Resumable subs, which includes calls to Sleep, rely on the internal message queue. There is no...
Page: 1  
2  
3  
4  
5  
6  
7