I have a list of proxies, each proxy goes to various sites and pulls the needed data from the sites. Currently it's doing this one at a time. But I'd like to have 10 - 20 tasks running at once so it's downloading from 20 sites in one go rather than just one.
Here's how I'm currently doing it:
private async Task<string> DownloadDataFromSite(string url)
{
// (await) Do Work.
return HTMLSourceCode;
}
I then loop through the proxies
foreach(Proxy p in proxies)
{
string source = await DownloadDataFromSite(site);
}
Is Parallel.ForEach suitable for such a task? I've tried it, but the problem I'm having at the moment is not being able to await.