Android Question Problem with MsgboxAsync

GaNdAlF89

Active Member
Licensed User
Longtime User
Hello everyone! I have to update an old project, and I have to replace the old Msgbox with the new MsgboxAsync. With this last, I have a strange behavior: after invoking the MsgboxAsync, the message appears on the display but the execution continues regardless. I think I have mistaken the management of synchrony. Here is the piece of code in question:

B4X:
Sub Activity_Create (FirstTime As Boolean)

    Set_App 'I call this function

    Set_Layout

    'etc...
End Sub

Sub Set_App

If File.Exists("percorso","abc.de") = False Then 'First run
        
    Dim ro As Object = Msgbox2Async("File di avvio non trovato." & CRLF & "Utilizzare il fle di default?","File mancante","SÌ","","NO",Null,False)
    Wait For (ro) Msgbox_Result (res As Int)
    If res = DialogResponse.POSITIVE Then
        'etc

End Sub

After the execution of the line with the Wait For, the message is shown correctly on the display, but the execution continues with the Set_Layout function (as if the execution of Set_App were interrupted and continues with the next function present in the Activity_Create). Can you tell me where am I wrong? Thank you so much
 

DonManfred

Expert
Licensed User
Longtime User
Make Set_App a resumeable sub and wait for finish....

 
Upvote 0

GaNdAlF89

Active Member
Licensed User
Longtime User
Make Set_App a resumeable sub and wait for finish....

Thank you, I will proceed with this.
 
Upvote 0

GaNdAlF89

Active Member
Licensed User
Longtime User
Another question, I have this simple:
B4X:
MsgboxAsync("Internal error.","Attention")
Wait For Msgbox_Result (res0 As Int)
How can I wait for the user clicks on "ok" button? Do I have to wait, with the same logic as before, for the entire function containing the MsgboxAsync?
 
Last edited:
Upvote 0

GaNdAlF89

Active Member
Licensed User
Longtime User
And...
@Erel I have a BTSerialPrinter_Connected (Success as Boolean) event, in which I show a MsboxAsync in the Success=False case. How can I handle this, to wait for it?

Is this code right?
B4X:
Sub BTSerialPrinter_Connected (Success As Boolean) As ResumableSub
'etc...
Return Null
End Sub

Sub BTPrinterConnect
Wait For BTSerialPrinter.Connect(params...) Complete (Result As Object)
End Sub
 
Upvote 0

GaNdAlF89

Active Member
Licensed User
Longtime User
Please don't do it. This is a public forum.
Your code is wrong, however it is also not related to this thread so you should start a new one.
Ok, sorry. I started a new thread for new question.

Another question, I have this simple:
B4X:
MsgboxAsync("Internal error.","Attention")
Wait For Msgbox_Result (res0 As Int)
How can I wait for the user clicks on "ok" button? Do I have to wait, with the same logic as before, for the entire function containing the MsgboxAsync?
How can I do in this case?
 
Upvote 0

Sabotto

Well-Known Member
Licensed User
B4X:
Msgbox2Async(" Do you want to do this?", "Question", "Yes", "Cancel","No" , Null, True)

    Wait For msgbox_result (Result As Int)

    Select Case Result

        Case DialogResponse.POSITIVE

            Log("Yes")

        Case DialogResponse.CANCEL

            Log("Cancel")

        Case DialogResponse.NEGATIVE

            Log("No")

    End Select
 
Upvote 0
Top