我正在使用多个线程来执行某些进程,并且我想在进度条中显示总进度,以便如何以安全的方式执行ProgressBar1.Increment(1)?
Public Sub thread1process()
For i = 0 To t1.Rows.Count - 1
t1.Rows(i)("cname") = "Thread1"
t1.Rows(i)("PD") = i
t1.Rows(i)("PDP") = i
t1.Rows(i)("TPD") = i
t1.Rows(i)("TPDP") = i
ProgressBar1.Increment(1)
Next
End Sub
Public Sub thread2process()
For i = 0 To t2.Rows.Count - 1
t2.Rows(i)("cname") = "Thread2"
t2.Rows(i)("PD") = i
t2.Rows(i)("PDP") = i
t2.Rows(i)("TPD") = i
t2.Rows(i)("TPDP") = i
ProgressBar1.Increment(1)
Next
End Sub
我如何在同一时间从多个线程增加一个公共变量?
答案 0 :(得分:1)
答案 1 :(得分:0)
您希望理想地在与主网页不同的线程上更新GUI。 Background worker thread应该适合你。