I found the problem, In addition to what is indicated by
@drgottjr
class does not accept callsubdelayed.
replace it with returns a variable
and converted the function to resumabled
in b4xmaginpage
[CODE lang="b4x" title="B4XMainPage"]Sub Class_Globals
Private Root As B4XView
Private xui As XUI
Private conectividad As clsControlConectividad
Private resultado_conectividad As String
End Sub
Public Sub Initialize
' B4XPages.GetManager.LogEvents = True
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.
Private Sub Button1_Click
xui.MsgboxAsync("Hello world!", "B4X")
conectividad.Initialize("a","b","B4XMainPage")
wait for(conectividad.gsub_control_conectividad) complete (resultado As String)
CallSubDelayed(Me,resultado)
End Sub
Sub a
xui.MsgboxAsync("A!", "B4X")
End Sub
Sub b
xui.MsgboxAsync("B!", "B4X")
End Sub[/CODE]
in class module
[CODE lang="b4x" title="class module"]Sub Class_Globals
Public mb_conectado As Boolean = False
Public mdt_fecha_control_conectado As Long = 0
Dim msObjeto As String = "clsControlConectividad"
Private ls_funcion,ls_funcion_err,ls_modulo As String
End Sub
'Initializes the object. You can add parameters to this method if needed.
Public Sub Initialize (ms_funcion As String, ms_funcion_err As String, ms_modulo As String)
ls_funcion = ms_funcion
ls_funcion_err = ms_funcion_err
ls_modulo = ms_modulo
End Sub
Sub gsub_control_conectividad As ResumableSub
Dim lo_job As HttpJob
mb_conectado = True
If mdt_fecha_control_conectado < DateTime.Now Then
mb_conectado = False
Try
lo_job.Initialize("lo_job", Me)
lo_job.GetRequest.Timeout = 50000000
lo_job.Download("http://www.google.com")
Wait For (lo_job) JobDone(lo_job As HttpJob)
If lo_job.Success Then
mb_conectado = True
End If
lo_job.Release
Catch
Log(DateTime.Time(DateTime.Now) & " : " & LastException)
End Try
If lo_job <> Null Then
If lo_job.IsInitialized Then
lo_job.Release
End If
End If
Dim lo_per As Period
lo_per.Initialize
If mb_conectado = False Then
lo_per.Seconds = 5
Else
lo_per.Seconds = 20
End If
mdt_fecha_control_conectado = DateUtils.AddPeriod(DateTime.Now, lo_per)
If mb_conectado Then
If ls_funcion <> "" Then
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Return ls_funcion
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
End If
Else
If ls_funcion_err <> "" Then
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Return ls_funcion_err
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
End If
End If
End If
End Sub
[/CODE]