B4J Question [SOLVED] Wait for ... question

rosippc64a

Active Member
Licensed User
Longtime User
Hi All,
I use the wait for... but maybe not good.
My problem is, that this first wait for ended before the last initdb run. What is the righ approach when there is multiple wait for in called subs ?
Thanks in advance
Steven
B4X:
    Wait For(Codebase.init) Complete (Result As String)   
    If Result.Length>0 Then   
        ...
B4X:
Public Sub init As ResumableSub
    Dim res As String = ""
    Try
        initColors
        Wait For(initdb) Complete (res As String)
        ...
    Return res
end sub
B4X:
private Sub initdb As ResumableSub
...
        sql.InitializeAsync("PostgreSQL", "org.postgresql.Driver", $"jdbc:postgresql://${DBLocation}:${DBPort}/postgres"$, DBUsername, DBPassword)
        wait for PostgreSQL_Ready (Success As Boolean)
        If Success Then
    ...   
    Return res
End Sub
 

trepdas

Active Member
Licensed User
Longtime User
thank you for asking this. I'm facing s similiar problem , waiting also for help on this...
wait for is not waiting for complete as requested...
 
Upvote 0

rosippc64a

Active Member
Licensed User
Longtime User
Sorry Erel, my problem is solved. The log showed right program flow.

B4X:
before: Wait For(Codebase.init)
Init colors
Read color settings map...
before: Wait For(initdb)
Initdb
before: wait for PostgreSQL_Ready
after: wait for PostgreSQL_Ready
DBVersion = 35
after: Wait For(initdb)
Init:
after: Wait For(Codebase.init)

My mistake was that in the ... line (see below) there was additional code what made secondary exception, so the "if Result.length" line never executed. Moreover weeks ago I encountered some similar problem and I believed I did some mistake concerning nested "wait for..."
Thank you!
B4X:
    Wait For(Codebase.init) Complete (Result As String)
    Log("after: Wait For(Codebase.init)")
    ... <--------
    If Result.Length>0 Then
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…