我有一个执行语句,它运行巨大数据库的dbcc checkdb。为此,我正在运行一名后台工作人员。这就是我想要的。
1.我希望主UI线程等到后台工作者完成。 2.一旦后台工作人员完成,关闭表单。
但我似乎无法为选框进度条设置动画。这是我试过的:
任何人都可以解释一下解决方案是什么?非常感谢提前。
答案 0 :(得分:0)
假设您在表单上将ProgressBar设置为Marquee样式和BackgroundWorker组件,那么此演示应指向正确的方向:
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Me.Enabled = False
ProgressBar1.Show()
BackgroundWorker1.RunWorkerAsync()
End Sub
Private Sub BackgroundWorker1_DoWork(sender As Object, e As System.ComponentModel.DoWorkEventArgs) Handles BackgroundWorker1.DoWork
Threading.Thread.Sleep(5000)
End Sub
Private Sub BackgroundWorker1_RunWorkerCompleted(sender As Object, e As System.ComponentModel.RunWorkerCompletedEventArgs) Handles BackgroundWorker1.RunWorkerCompleted
ProgressBar1.Hide()
Me.Enabled = True
End Sub
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
ProgressBar1.Hide()
End Sub