Parallelizing some LINQ to XML
- by Lol coder
How can I make this code run in parallel?
List<Crop> crops = new List<Crop>();
//Get up to 10 pages of data.
for (int i = 1; i < 10; i++)
{
//i is basically used for paging.
XDocument document = XDocument.Load(string.Format(url, i));
crops.AddRange(from c in document.Descendants("CropType")
select new Crop
{
//The data here.
});
}