I have a URLconnection method that uses send(“GET”,URL) to put data into a TextArea. On the ContentReceived event, I am able to process this data. Works great. But I’m not sure how to handle multiple of these in sequence. We obviously want the first to complete before we launch the next. I could bury launching the next GET at the end of the prior ContentReceived event (to avoid collisions) but that seems like a hack.
I could also create a Global FLAG that indicates status of each GET/ContentReceived and check that with a timer before launching the next GET. But Global Flags tell me I’m thinking about this wrong. I also worry about unintended race conditions with this approach.
What is the right way to deal with multiple asynchronous interactions with server data using URLconnection?