我有以下代码:
progressBar1.Minimum = 0;
progressBar1.Maximum = Results.Count;
foreach (MyClass cls in Results)
{
progressBar1.Value += 1;
// Go to DB and get large quantity of data
cls.GetHistoryData();
}我想要做的是将处理转移到另一个线程,以便progressBar1正确更新。我发现了一个article,它暗示我应该能够在进度条上使用Invoke方法,但似乎没有。
发布于 2010-11-19 18:37:25
您可以像这样启动一个新线程:
Thread t1 = new Thread(methodnametocall);
t1.start();
void methodnametocall()
{
this.Invoke((MethodInvoker)delegate
{
control to update;
}
});https://stackoverflow.com/questions/4224146
复制相似问题