I have just started playing around with Narek Adonts' Background Task library and it seems to be really impressive. So good in fact that I thought I might be missing some significant side-effects of using the library. Are there any?
I know the background task can't update the UI but is there a thread safe way of sharing a variable between the background and UI threads so that the following would be safe?
Even if this is not possible, the Background Task library seems to be very useful in keeping the UI thread functional.
I know the background task can't update the UI but is there a thread safe way of sharing a variable between the background and UI threads so that the following would be safe?
B4X:
Dim myBGTask As BackgroundTask
Dim progress as long
Dim timer1 As Timer
Sub MyTask
for i=1 to aBigNumber
doSomeHeavyDutyStuff
progress=i
next
End Sub
'runs in UI thread
Sub go
timer1.Initialize("timer1",500)
timer1.Enabled=True
myBGTask.Initialize("MyTask",Me,Array(Null))
End Sub
Sub timer1_Tick
Label1.text=progress
End Sub