case
- foreground saves data into storage and calls onTemporaryEvent
- nobody knows when background starts but it have to read data from storage
- foreground again saves data when background still runs but no onBacktounddate yet- can be a collision?
case
- foreground saves data into storage and calls onTemporaryEvent
- nobody knows when background starts but it have to read data from storage
- foreground again saves data when background still runs but no onBacktounddate yet- can be a collision?
on sim it's difficult to simulate it due to fast computer but on device?
or course I have a strange error (as usually recently on epix/f7) that suggesting collision
I don't know, but I would be very surprised if this would be possible. IMHO every app runs on 1 thread.
And it can be problem. 2 threads and one storage file.
It's enough background keeps storage in write state.
Not sure what you mean with the foreground calling "onTemporalEvent". Do you mean you registerForTemporalEvent()?
What are you seeing that makes you think there is an issue?
If you call Background.exit(null), onBackgroundData won't get called until you exit with non-null data
00:00:00 the last onTemporalEvent
00:01:00 foreground calls registerForTemporalEvent
2 cases
1. 00.05:00 foreground saves data and background reads data in onTemporalEvent
2. 00:05:00 background reads data in onTemporalEvent and forgets to close file at 00.05:01 foreground try to save data
A background services runs for no more than 30 seconds at a time.
What are you seeing when the foreground tries to save?
Error is always in foreground: Error Name: File Not Found Error or Error Name: System Error
And of course it happens from time to time (not like with bug in Venu SW when I saw hundreds for everybody).
I save in storage 2 things one key for BAG others for FOR and code looks like (line by line):
saveForAPP();// <---- never error
saveForBAG();// <--- from time to time, only this key is read by BAG in onTemporalEvent
Are you using setValue()/getValue() or setProperty()/getProperty()?
of course Storage.setValue()