C
C#16mo ago
stigzler

❔ Optimising multi-threaded web API calls

Hi all. I am looking to code a wrapper to access a web API (Screenscraper.fr). The API provides both metadata for games and also images via download urls. My question is about how best to approach this. Al I know about he web API is that it provides users with a variable number of "threads." I have no idea how this works from the Web API application side. Sadly, that means I don't know what counts as a "thread" from the application's point of view. The app is great, the documentation and support less so! I will need to be downloading text (the metadata - in either xml or json) and the images. Should I use a Parallel ForEach loop, or will this not count as "threads" on the API? Also, I'm going o finally try and get to grips with HttpClient - I understand you should only initiate one HttpClient and keep it 'live'? If so, I would presumably need to spawn a number of HttpClients totalling the users number of threads. How would I weave this in code? Hope make sense. Sorry, I'm not a professional developer, just a hobbyist!
6 Replies
Sossenbinder
Sossenbinder16mo ago
I assume threads on the api side means concurrent requests And for client side, parallel foreachasync or task whenall of the tpl are your best bets for concurrent I/O based http requests
Omnissiah
Omnissiah16mo ago
couldn't it be on the server side? like how many threads do you want to allocate to do stuff? also, address is Screenscraper.fr, not Screenscarper.fr ok looking at sscraper it's probably client threads
stigzler
stigzlerOP16mo ago
thanks - hat's where my reading's taking me. "TPL"?
Sossenbinder
Sossenbinder16mo ago
Task Parallel Library
stigzler
stigzlerOP16mo ago
thanks
Accord
Accord16mo ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.
Want results from more Discord servers?
Add your server