Soldato
- Joined
- 16 Nov 2003
- Posts
- 9,682
- Location
- On the pale blue dot
Hi guys.
I need to read 400+ files from the Internet which of course takes time, most of which is latency requesting the file as they are very small files. Therefore I want to dabble in threading to say do 10 simultaneous requests at once.
The difficult part is that I read the files into a hashtable which is processed further down the line, but threads do not return values so I can't execute 10 threads that read into the same hashtable, not to mention 10 threads trying to access the same variable at the same time is likely to cause some very nasty problems.
I'm a bit stumped on how to proceed. Has anyone done anything similar in the past, how can I collate the data the separate threads generate into one source?
I need to read 400+ files from the Internet which of course takes time, most of which is latency requesting the file as they are very small files. Therefore I want to dabble in threading to say do 10 simultaneous requests at once.
The difficult part is that I read the files into a hashtable which is processed further down the line, but threads do not return values so I can't execute 10 threads that read into the same hashtable, not to mention 10 threads trying to access the same variable at the same time is likely to cause some very nasty problems.
I'm a bit stumped on how to proceed. Has anyone done anything similar in the past, how can I collate the data the separate threads generate into one source?
. Hopefully the comments demonstrate it fine you don't actually need locking unless you got multiple writers/readers going on. Thread new/join etc.. should be similar because they are in java and c# is basically a copy
Delegates would work as well indeed. You could do the processing of your data as soon as it is received but that makes it slightly more complicated and might not be possible depending on what data you need for the processing.

