Есть метод, который парсит столбец таблицы с сайта. При нажатии на кнопку метод выполняется более 1-2 секунд. Как можно сделать, чтобы прогресс бар заполнялся относительно завершения работы метода. Сам метод:
void GetClosePrices(string Active)
{
var url = "https://finance.yahoo.com/quote/"+ Active + "/history?p=" + Active;
var web = new HtmlWeb();
var doc = web.Load(url);
HtmlNode collection = doc.DocumentNode.SelectSingleNode("//*[@id='Col1-1-HistoricalDataTable-Proxy']/section/div[2]/table/tbody");
int rowscount = collection.ChildNodes.Count + 1;
dataGridView1.Columns.Add(new DataGridViewColumn { HeaderText = Active, CellTemplate = new DataGridViewTextBoxCell()});
if (dataGridView1.Rows.Count == 0)
dataGridView1.Rows.Add(rowscount);
for (int i = 0; i < collection.ChildNodes.Count + 1; i++)
{
var nodes = collection.SelectSingleNode("tr[" + i + "]/td[5]");
if (nodes != null)
dataGridView1.Rows[i].Cells[dataGridView1.ColumnCount - 1].Value = nodes.InnerText.Replace('.', ',');
}
textBox1.Text = "";
}
Invoke. – Alexander Petrov Sep 15 '18 at 14:59HtmlWeb- это из библиотекиHtmlAgilityPack? Этот класс, вроде, не умеет асинхронно выполнять работу. Стало быть, для отображения прогресса загрузки не подойдет. – Alexander Petrov Sep 15 '18 at 15:01DataGridView, включите у него двойную буферизацию. – Alexander Petrov Sep 15 '18 at 15:03WebClient, например, а уже потом передавать их в HAP. – Alexander Petrov Sep 15 '18 at 15:56