如果这是异步的,它会返回没有错误,为什么它没有异步就抛出错误,异步在这个操作中毫无价值。
public Task<int> countUp()
{
string compare = txtTag.Text;
int count = 0;
for (int i = 0; i < dataGridView1.Rows.Count; i++)
{
if (compare == dataGridView1[0, i].Value.ToString())
{
BeginInvoke(new Action(() =>
{
count++;
txtCount.Text = count.ToString();
}));
}
}
return count;
}