B4J Question hot get BackgroundWorker from Main.bas

Status
Not open for further replies.

jinyistudio

Well-Known Member
Licensed User
Longtime User
Hi

I have add some BackgroundWorker as following, Could i get gate4dimmer and call their sub with callsub ? :)
B4X:
srvr.AddBackgroundWorker("gate4dimmer")
    srvr.AddBackgroundWorker("gate4mbtcp")
    srvr.AddBackgroundWorker("gate4mbrtu")
    srvr.AddBackgroundWorker("gate4slmp")
    '
    srvr.Start
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
You shouldn't directly call subs of these classes as they should be executed on the correct thread.

You can do something like:
B4X:
'Main code
Sub Process_Globals
 Public Gate4Dimmer1 As Gate4Dimmer1
 ...
End Sub

'Gate4Dimmer
Sub Initialize
 Main.Gate4Dimmer1 = Me
End Sub

Now you can use CallSubDelayed (Gate4Dimmer1, "SomeSub") to call a sub from the Main or any other module.
 
Upvote 0
Status
Not open for further replies.
Top