I have a web app that hits up multiple different APIs to collect data and add it to a database. Each API’s data goes into its own staging table in the DB for later processing. The app has a timer that launches a thread to get the data through a single URLConnection and each API is hit up sequentially.
I want to modify the app so that each API has it’s own thread. What are the pros and cons of having the URLConnection as a thread property vs. keeping an array of URLConnections at the app level?
so this got me thinking, because i need to do the same thing, i read fast at first, you meant you init url connection/ threads one by one, and you wait for server result to triger other data query ?
Currently the part of the app that does all the real work is in a single thread. That thread uses a single URLConnection to get the data from a single API, then the thread processes that data and inserts it into a database. Once it’s done with the first API, it then does the same thing with the next API. The calls to the various APIs are hard-coded into the Run event of the thread.
I had thought of that, but I have not worked with workers yet. I think I’ll try the threads first and if I don’t get what i’m looking for i’ll give the workers a try.
In any case, when processing the data if you run the risk of having to run more than a few milliseconds, make sure you call App.DoEvents or App.YieldToNextThread periodically to give active sessions the time they need to communicate with their connected browsers.