private void Start_Click(object sender, RoutedEventArgs e) { Start.IsEnabled = false; MContext mc = new MContext(); List <SKU> lsku = mc.SKUs.ToList(); foreach (SKU s in lsku) { s.AlloPrice = 0; s.AlloPromo = 0; s.ChangePrice = false; s.ComfyPrice = 0; s.ComfyPromo = 0; s.EldoradoPrice = 0; s.EldoradoPromo = 0; s.HotlinePrice = 0; s.RozetkaPrice = 0; s.RozetkaPromo = 0; s.TotalPrice = 0; s.TotalPromo = 0; mc.SaveChanges(); } List <string> lUrlComfy = new List <string>(); List <string> lUrlRozetka = new List <string>(); List <string> lUrlAllo = new List <string>(); List <string> lUrlEldorado = new List <string>(); foreach (Subcategory s in CheckSubcategory.SelectedItems) { lUrlComfy.Add(s.UrlComfy); lUrlRozetka.Add(s.UrlRozetka); lUrlAllo.Add(s.UrlAllo); lUrlEldorado.Add(s.UrlEldorado); } UrlCompetitors uc = new UrlCompetitors() { lUrlComfy = lUrlComfy, lUrlRozetka = lUrlRozetka, lUrlAllo = lUrlAllo, lUrlEldorado = lUrlEldorado }; Thread th = new Thread(SeeTread); th.Start(uc); }
void SeeTread(object obj) { UrlCompetitors uc = obj as UrlCompetitors; //создвем 4 потока запускающих парсинг данных Thread[] th = new Thread[4]; th[0] = new Thread(Comfy); th[0].Start(uc.lUrlComfy); th[1] = new Thread(Rozetka); th[1].Start(uc.lUrlRozetka); th[2] = new Thread(Allo); th[2].Start(uc.lUrlAllo); th[3] = new Thread(Eldorado); th[3].Start(uc.lUrlEldorado); Thread ProcTh = new Thread(SetProcTh); ProcTh.Start(); for (int i = 0; i < th.Length; ++i) { th[i].Join(); } MessageBox.Show("Обновление БД завершенно"); }