If I am running a server and I have a background worker (which is a class) running, how can I read properties, modify properties and run methods of this class from other modules?
TIA
Sample Code:
B4X:
'--- Main code ---
Sub Process_Globals
Public EmailMsgs1 As clsEmailMsgs
...
End Sub
Sub AppStart (Args() As String)
...
srvr.AddBackgroundWorker("clsEmailMsgs")
StartMessageLoop
end sub
'--- clsEmailMsgs Code ---
Sub Initialize
Main.EmailMsgs1 = Me
End Sub
'--- Module1 Code ---
if Main.EmailMsgs1.Running=False then 'How can I rewrite these lines using "Wait For"?
Main.EmailMsgs1.Running = true
Main.EMailMsgs1.StartEmailing
end if
Hi Gunther,
I've worked a lot with classes, but this is a special case. It is a background worker class. To access the background worker, because it is on a different thread, the recommended method is:
I want to know if it is possible to use "Wait For" instead of "CallSubDelayed" to access properties and methods in the background thread. This will make the code more readable because I can retrieve values from the background class properties.
If you are accessing primitive or string variables then you don't need to do anything special. Just get them directly.
Wait For and CallSubDelayed are not interchangeable. If you want to call a sub in the worker class instance then you need to use CallSubDelayed. You can then call Wait For and wait for an "event" that is raised from the worker class with CallSubDelayed.