Im working on a project like this:
- An app will be collecting data from sensors (sometimes once per second).
- The data is shown on screen until new data is readed
- The data will be saved to a local SQLite database, but
- The data also will be send to a server (each entry needs to be in a POST).
So, my idea, In the Main thread, receive data, prent to scren, save to DB and insert it on a array.
In a separate thread, a loop to send the data syncronously with HTTPSecureSocket, on success, pop the item, write to the DB as Item sended and send next item.
To be conssidered, internet sometimes could fail or be very slow.
So, It is safe to insert on an array and pop in separate threads?
What would be the best opproach for this situation?