Task<string>[] tableOfWebClientTasks = new Task<string>[taskCount];
for (int i = 0; i < taskCount; i++)
{
tableOfWebClientTasks[i] = new WebClient().DownloadStringTask(allUrls[count - i - 1]);
}
Task.Factory.ContinueWhenAll(tableOfWebClientTasks, tasks =>
{
Parallel.ForEach(tasks, task =>
{
//Here I have result from each task.
//But information which url is executed on this task, is lost.
});
});
I could, for example, create class (with two public property, one for task, and second for url) and return instance. But This method i connected with others methods.
Have you some solution for this issue?
If you want to be able to associate your tasks with the url that created them you could use a dictionary to do the mapping: