I am trying to get a class to work using Wait For or Sleep .... command, but I am having trouble. If I convert the class to a module, than the code will work. Is there a workaround?
B4XMainPage:
#Region Shared Files
#CustomBuildAction: folders ready, %WINDIR%\System32\Robocopy.exe,"..\..\Shared Files" "..\Files"
'Ctrl + click to sync files: ide://run?file=%WINDIR%\System32\Robocopy.exe&args=..\..\Shared+Files&args=..\Files&FilesSync=True
#End Region
'Ctrl + click to export as zip: ide://run?File=%B4X%\Zipper.jar&Args=Project.zip
Sub Class_Globals
Private Root As B4XView
Private xui As XUI
End Sub
Public Sub Initialize
End Sub
'This event will be called once, before the page becomes visible.
Private Sub B4XPage_Created (Root1 As B4XView)
Root = Root1
Root.LoadLayout("MainPage")
End Sub
'You can see the list of page related events in the B4XPagesManager object. The event name is B4XPage.
Sub Button1_Click
calc
End Sub
Sub calc
Dim cSum As Sum
Wait For(cSum.Sum(1, 2)) Complete (Result As Int)
Log("result: " & Result)
Log("after sum")
End Sub
Sum:
Sub Class_Globals
End Sub
'Initializes the object. You can add parameters to this method if needed.
Public Sub Initialize
End Sub
'Code module
Sub Process_Globals
'These global variables will be declared once when the application starts.
'Public variables can be accessed from all modules.
End Sub
public Sub Sum(a As Int, b As Int) As ResumableSub
Sleep(100)
Log(a + b)
Return a + b
End Sub
Last edited: