I have translated many of my MsgBox2 instances to MsgBox2Async with no problems, but I have a few where I am running into the restriction of not being able to use it in a Sub that returns a result. Maybe someone can point me to a way of handling this. Here is a simple example:
In a service, I call the activity to run a messagebox:
I am looking for the result to be returned. My code with MsgBox2 was:
I want to use this
But using MsgBox2Async, return values are not allowed from the Sub "Confirm".
Is there any way to work around this? Can Sender somehow be used to call back to the Sub in the service?
Or is there some way to see the iResult from within the Calling Sub in the service?
In a service, I call the activity to run a messagebox:
B4X:
' In the service module:
bFadeStopClearTracks = CallSub2(TMM_Run, "Confirm", "Empty the Queue?")
B4X:
' In the activity module TMM_Run:
' Returns True if "Yes" is clicked, False if "No" is clicked
Sub Confirm(Message As String) As Boolean
Dim bResult As Boolean
bResult = (Msgbox2(Message,"Music Machine","Yes","No","", _
TMM.gbmpLogo36x36) = DialogResponse.POSITIVE)
Return bResult
End Sub
B4X:
Sub Confirm(Message As String) as Boolean
Msgbox2Async(Message, "Music Machine", "Yes", "No", "", _
TMM.gbmpLogo36x36, False)
Wait For MsgBox_Result (iResult As Int)
Return (iResult = DialogResponse.POSITIVE)
End Sub
Is there any way to work around this? Can Sender somehow be used to call back to the Sub in the service?
Or is there some way to see the iResult from within the Calling Sub in the service?