Android Question [SOLVED] Wait for calling itself again if fail

makis_best

Well-Known Member
Licensed User
Longtime User
Hi

I have a sub I call it with wait for and CallSub3(SyncClass1, "ListItems_ReplaseInto", "1996-11-05", True)
I want if wait for return false to try calling itself again.
The code I use is like that but I am not sure if it is absolutely correct.


B4X:
Wait For (CallSub3(SyncClass1, "ListItems_ReplaseInto", "1996-11-05", True)) Complete (Result As Boolean)
        If Result = False Then
            Msgbox2Async("Warning!!", "The process not complete successfully. Try again?", "OK", "", "NO", Null, True)
            Wait For Msgbox_Result (Result1 As Int)
            If Result1 = DialogResponse.POSITIVE Then
                Wait For (CallSub3(SyncClass1, "ListItems_ReplaseInto", "1996-11-05", True)) Complete (Result As Boolean)  --->  Some code here?
            End If
        End If

Thank you.
 

JohnC

Expert
Licensed User
Longtime User
Are you sure you can even use Wait For with a CallSub3?
 
Upvote 0

makis_best

Well-Known Member
Licensed User
Longtime User
Yes...
I use it with no problem...
Run once... but when fail not running again.
The only problem I had is how to calling itself again.
 
Upvote 0

Keith Flanagan

Member
Licensed User
I have not tested this but could you use a loop like the code below:

B4X:
Dim Retry As Boolean = True

    Do While Retry = True
        Wait For (CallSub3(SyncClass1, "ListItems_ReplaseInto", "1996-11-05", True)) Complete (Result As Boolean)
        If Result = False Then
            Msgbox2Async("Warning!!", "The process not complete successfully. Try again?", "OK", "", "NO", Null, True)
            Wait For Msgbox_Result (Result1 As Int)
            If Result1 = DialogResponse.POSITIVE Then
                Retry = True
            Else
                Retry = False
            End If
        End If
    Loop
 
Upvote 0

JohnC

Expert
Licensed User
Longtime User
Maybe this:
B4X:
Dim Redo as Boolean

Do
    Redo = False
    Wait For (CallSub3(SyncClass1, "ListItems_ReplaseInto", "1996-11-05", True)) Complete (Result As Boolean)
        If Result = False Then
            Msgbox2Async("Warning!!", "The process not complete successfully. Try again?", "OK", "", "NO", Null, True)
            Wait For Msgbox_Result (Result1 As Int)
            If Result1 = DialogResponse.POSITIVE Then
                Redo = True
            End If
        End If
Loop While Redo = True
 
Upvote 0
Top