clean-code-javascript | : bathtub : Адаптированные для JavaScript | Translation library
kandi X-RAY | clean-code-javascript Summary
kandi X-RAY | clean-code-javascript Summary
clean-code-javascript
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of clean-code-javascript
clean-code-javascript Key Features
clean-code-javascript Examples and Code Snippets
Community Discussions
Trending Discussions on clean-code-javascript
QUESTION
I'm trying to call to the Google PageSpeed Insights API with mutliple input urls read from a .txt
file and to output the results to a .csv
.
I wrote a console app to try to fire these requests off, and then as they come back to add them to a list, and when they are all done, to write the list
to the .csv
file (async got a little nutty when trying to write the responses immediately to the .csv
).
My code it below, and far from optimized. I come form a JavaScript background, where I usually don't use web workers or any other managed new threads, so I was trying to do the same in C#.
- Can I run do these multiple
WebRequest
s and write them to a collection (or output file) without using multiple threads and have them all run in parallel, not having to wait for each request to come back before handling the next one? - Is there a cleaner way to do this with callbacks?
- If threads or
BackgroundWorker
s are needed, what's a Clean Code way of doing this?
ANSWER
Answered 2017-Jul-12 at 14:16Can I run do these multiple WebRequests and write them to a collection (or output file) without using multiple threads and have them all run in parallel, not having to wait for each request to come back before handling the next one?
Sure thing.
Is there a cleaner way to do this with callbacks?
You can always iterate over the input lines and grab a collection of the tasks that are all running.
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install clean-code-javascript
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page