Good morning everyone.
I rarely post here because I usually try to solve my coding problems by browsing through the forum and the web, but this time I can’t figure it out.
I have an issue with the Threading library (Ver.1.10) when starting a thread. I’ve posted the problematic code, but if needed, I can provide the complete app.
The code
The istruction at line 16
does not start the sub ConnectToServer_Task at all. I have tried both in Release mode and Debug mode—nothing works. Moreover, the debugger doesn’t report any error. Stepping through with F8 in debug mode, the debugger simply skips over it and continues with the next instruction, without invoking the mentioned sub.
Any advice? Thank you.
BTW.
I'm using B4A v.13.00
Device with Android v.11
I rarely post here because I usually try to solve my coding problems by browsing through the forum and the web, but this time I can’t figure it out.
I have an issue with the Threading library (Ver.1.10) when starting a thread. I’ve posted the problematic code, but if needed, I can provide the complete app.
The code
B4X:
Sub Globals
Dim Socket As JavaObject
Dim arr() As String
Dim t As Thread
End Sub
Sub Activity_Create(FirstTime As Boolean)
Activity.LoadLayout("timeguardian1")
t.Initialise("ConnectToServer_Task") ' Initializes thread
arr = Array As String("192.168.1.50","12345") 'IP address of PC, open port of PC
End Sub
Sub ConnectToServerAsync()
Log("log1")
If t.IsInitialized Then Log("is initialized")
t.Start(Me, "ConnectToServer_Task", arr) ' !!!!This instruction does not start the sub ConnectToServer_Task!!!!
Log("log2")
End Sub
Sub ConnectToServer_Task()
Log("log3")
Dim jo As JavaObject
Try
jo.InitializeNewInstance("java.net.Socket", Array As Object(arr))
Log("Connection successful!")
CallSubDelayed2(Me, "ConnectionEstablished", jo)
Catch
Log("Error during connection: " & LastException.Message)
End Try
End Sub
The istruction at line 16
B4X:
t.Start(Me, "ConnectToServer_Task", arr)
Any advice? Thank you.
BTW.
I'm using B4A v.13.00
Device with Android v.11