B4J Question [SOLVED] Resumable Sub in own UI Library not completing

rwblinn

Well-Known Member
Licensed User
Longtime User
Developing a library jCCUXML2Map with resumable subs to be used in UI application.

When using in the MainForm the library sub Get_Device_List, nothing happens after Wait For...?
What is wrong in the code?
Note: when using the library code direct and without resumable sub in the Button Click Event, its working.

Example Code Snippet.
B4X:
Private ccu as CCUXML2Map
MainForm Button Click
B4X:
Private Sub ButtonRefresh_Click
    Dim rs As ResumableSub = ccu.Get_Device_List 
    Wait For(rs) complete (DeviceList As List)
    Log("THIS IS NEVER SHOWN")
    If DeviceList.Size > 0 Then
      ' Take Action
    End If
End Sub

Library Code jCCUXML2Map
B4X:
Public Sub Get_Device_List As ResumableSub
    Dim ReturnList As List
    Dim j As HttpJob
    ReturnList.Initialize
    j.Initialize("", Me)
    j.Download(Get_Device_List_Url)
    Wait For (j) JobDone(j As HttpJob)
    If j.Success Then
        ReturnList = Parse_Device_List(j.GetString)
    Else
        Log($"[ERROR] Get device list failed (${j.ErrorMessage})."$)
    End If
    j.Release
    Return ReturnList
End Sub
 

Star-Dust

Expert
Licensed User
Longtime User
It will not work when compiled as a jar library. The compiler will not treat it as a resumable sub. Make it a b4xlib. Simpler and more powerful.
If I'm not mistaken it could be both. One part in Jar and one part in B4XLib. As was done for okHttpUtils.
 
Upvote 0

rwblinn

Well-Known Member
Licensed User
Longtime User
Created a new CCUXML2Map.b4xlib in the B4J additional libraries folder.
Simply took the ccuxml2mapbas file from the "jar"-version.
Added a manifest.txt with dependencies (i.e. B4J.DependsOn=jOkHttpUtils2,xml2map) and packed.

This solution works.

Thanks for steer = this is my first b4xlib.
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…