Android Question Wait in class - How to make it work ?

Mauricio Pereira

Member
Licensed User
Longtime User
I couldn't get wait to work like wait in a small class.
I'm definitely making a mistake.
I am attaching a class (Savearq) where a wait not wait.
Thanks in advance to anyone who can help.

Class Savearq:
Sub Class_Globals
    Private DialogLayout As CustomLayoutDialog
    Private NomeModelo As FloatLabeledEditText
    Dim SFF As StringFunctions
    Dim IME As IME
End Sub

'Initializes the object. You can add parameters to this method if needed.
Public Sub Initialize
    IME.Initialize("IME")
    
End Sub
Sub Savefile
    Dim SF As Object = DialogLayout.ShowAsync("File name to be saved", "Ok", "", "", Null, True)
    DialogLayout.SetSize(100%x, 250dip)
    Wait For (SF) Dialog_Ready(pnl As Panel)  ' <=======  WAIT NOT WAIT HERE !
    pnl.LoadLayout("DialogLayout")
    
    NomeModelo.EditText.RequestFocus
    CallSubDelayed(Me,"SetKeyboard1")

    
    DialogLayout.GetButton(DialogResponse.POSITIVE).Enabled = True
    Wait For (SF) Dialog_Result(res As Int)
    'force the keyboard to hide
    NomeModelo.EditText.Enabled = False
        
    If res = DialogResponse.POSITIVE  Then
        If  SFF.Len(NomeModelo.EditText.Text) > 0 Then
            Main.XXX = NomeModelo.EditText.Text
        End If
    End If
End Sub
Sub SetKeyboard1
    Sleep(100)
    IME.ShowKeyboard(NomeModelo.EditText)
End Sub
 
Last edited:

Mauricio Pereira

Member
Licensed User
Longtime User
Show your code.
The code is very simple (in the activity that calls the class):
----------------------------
Dim s as Savearq
--------------------------
s.Initialize
CallSub(s,"Savefile")
--------------------------------
The program enters the class but does not wait for the wait response.
 
Upvote 0

teddybear

Well-Known Member
Licensed User
The code is very simple (in the activity that calls the class):
----------------------------
Dim s as Savearq
--------------------------
s.Initialize
CallSub(s,"Savefile")
--------------------------------
The program enters the class but does not wait for the wait response.

Try to use s.Savefile instead
 
Upvote 0

agraham

Expert
Licensed User
Longtime User
Remember that WaitFor causes an immediate return from the Sub containing the WaitFor and continues running code after the call to the Sub. So you have to, in this case, invoke
Wait For(s.Initialize) Complete (Result As Int)
to wait for the Resumable Sub Initialize to complete.
 
Upvote 0

Mauricio Pereira

Member
Licensed User
Longtime User
Remember that WaitFor causes an immediate return from the Sub containing the WaitFor and continues running code after the call to the Sub. So you have to, in this case, invoke
Wait For(s.Initialize) Complete (Result As Int)
to wait for the Resumable Sub Initialize to complete.
Agraham,
Sorry but I didn't understand exactly what to do.
The project (attached) is simple and was made exactly to test the functionality.
For me it's a strange Wait for that doesn't work like wait for...
More than 50 years ago (I'm 76 years old) when programming in Autocoder it was much simpler...:D:D
 

Attachments

  • Test.zip
    38.4 KB · Views: 68
Upvote 0

Brian Dean

Well-Known Member
Licensed User
Longtime User
. . . when programming in Autocoder it was much simpler
Do you mean Autocoder with word marks as in IBM 1401? If so I am afraid that you cannot use that as an excuse; there are several members of that vintage on this forum and some of them are "Experts".
 
Upvote 0

agraham

Expert
Licensed User
Longtime User
You need to declare Savefile As ResumableSub and return something from it even if you don't want to use the return value.
You need to invoke it With
Wait For (s.Savefile) Complete(Result As Object)
 

Attachments

  • Test2.zip
    12.4 KB · Views: 86
Last edited:
Upvote 1

Similar Threads

  • Question
Android Question Wait For
Replies
4
Views
792
  • Question
Android Question wait for...
Replies
2
Views
743
  • Question
Android Question wake at
Replies
3
Views
585
Top