private void StartParsing(IParse parser) { var firstUrl = URLTextBox.Text; var nextUrl = firstUrl; var countArticles = Convert.ToInt32(PagesCounTextBox.Text); ChangeControlInMainUi(progressBar1, () => progressBar1.Value = 0); ChangeControlInMainUi(progressBar1, () => progressBar1.Maximum = countArticles); for (; progressBar1.Value < countArticles && nextUrl != null; ChangeControlInMainUi(progressBar1, () => progressBar1.Value += 1)) { ChangeControlInMainUi(PersentLabel, () => PersentLabel.Text = $@"Парсится {progressBar1.Value} статья из {progressBar1.Maximum}({(progressBar1.Value) * 100 / progressBar1.Maximum}%)"); var result = parser.ParseSpecificArticle(nextUrl); ChangeControlInMainUi(URLTextBox, () => URLTextBox.Text = nextUrl); if (result != null) { _persons.AddRange(result); foreach (var item in result) { ChangeControlInMainUi(ReturnedEmailDataGrid, () => ReturnedEmailDataGrid.Rows.Add(item.Fio, item.Email)); } } nextUrl = parser.GetNextArticle(nextUrl); } }