B4J Question How to stop(delete) BackgroundWorker

jinyistudio

Well-Known Member
Licensed User
Longtime User
Hi

With server, I can Add somme BackgroundWorker. How could i stop(or delete) BackgroundWorker ? :(
 

MichalK73

Well-Known Member
Licensed User
Longtime User
Add in Main
B4X:
Dim StopTimer as Boolean

In module BackgroundWorker

B4X:
'Class: SomeTask
Sub Class_Globals
   Private timer1 As Timer  
End Sub

Public Sub Initialize
   timer1.Initialize("timer1", 10 * DateTime.TicksPerMinute)
   timer1.Enabled = True
   StartMessageLoop '<- don't forget!
End Sub

Sub Timer1_Tick
   'do the work required
If Main.StopTimer then
    timer1.Enabled = False
Else
    timer1.Enabled = True
EndIf
' Code for timer1
End Sub
 
Upvote 0

jinyistudio

Well-Known Member
Licensed User
Longtime User
Hi,Erel

your mean is

B4X:
Sub Timer1_Tick
   'do the work required
If Main.StopTimer then
    timer1.Enabled = False
    StopMessageLoop             <<------  add here 
Else
    timer1.Enabled = True
EndIf
' Code for timer1
End Sub
 
Upvote 0
Top