protected internal static void GetAutomobileSubFamily(string href, Guid id) { try { //Parallel.ForEach() //Parallel.ForEach(listOfFamiliesHrefs, href => WebClient WebClient = new WebClient(); string page = WebClient.DownloadString(href); HtmlDocument Doc = new HtmlDocument(); Doc.LoadHtml(page); var div = Doc.DocumentNode.SelectNodes("//div[@class='text']").Descendants("center"); //Parallel.ForEach(div, elem => foreach (var elem in div) { var hrefs = elem.SelectNodes(".//a"); if (hrefs != null) { //Parallel.ForEach(hrefs, link => foreach (var link in hrefs) { // using (CarDbModel db = new CarDbModel()) // { SubFamily subFamily = new SubFamily { SubFamilyName = elem.InnerText.Trim(), SubFamilyUrl = "http://www.autosvit.com.ua/" + link.GetAttributeValue("href", "/tech"), FamilyId = id }; subFamilies.Add(subFamily); // db.SubFamilies.Add(subFamily); // db.SaveChanges(); listOfSubFamiliesHrefs.Add(subFamily.SubFamilyUrl); } } catch (Exception ex) { Console.WriteLine(ex.Message); } }