在完成我的后台工作人员的操作之前,进度条重复了两到三遍
这段代码:
Private Sub BackgroundWorker1_DoWork(sender As System.Object, e As System.ComponentModel.DoWorkEventArgs) Handles BackgroundWorker1.DoWork
'Load Data
For i As Integer = 0 To ListData.Count
BackgroundWorker1.ReportProgress((i / ListData.Count) * 100)
Next
If BackgroundWorker1.CancellationPending Then
e.Cancel = True
End If
End Sub
Private Sub BackgroundWorker1_ProgressChanged(sender As System.Object, e As System.ComponentModel.ProgressChangedEventArgs) Handles BackgroundWorker1.ProgressChanged
Me.ProgressBar1.Value = e.ProgressPercentage
End Sub
Private Sub BackgroundWorker1_RunWorkerCompleted(sender As System.Object, e As System.ComponentModel.RunWorkerCompletedEventArgs) Handles BackgroundWorker1.RunWorkerCompleted
'set datasource of DatagridView
ProgressBar1.Style = ProgressBarStyle.Blocks
End Sub
在我的加载表单中
BackgroundWorker1.WorkerReportsProgress = True
BackgroundWorker1.WorkerSupportsCancellation = True
BackgroundWorker1.RunWorkerAsync()
ProgressBar1.Style = ProgressBarStyle.Marquee
请帮我