#Region "---------------再開一個線程顯示進度條---------------"PrivateSub waitstart()Me.Cursor = Cursors.WaitCursor '光標為沙漏BackgroundWorker1.RunWorkerAsync() '開啟多線程顯示進度條EndSubPrivateSub waitend()BackgroundWorker1.CancelAsync() '停止多線程Me.Cursor = Cursors.Default'光標為箭頭EndSubPrivateSub BackgroundWorker1_DoWork1(sender AsObject, _e As System.ComponentModel.DoWorkEventArgs) Handles BackgroundWorker1.DoWorkDim worker As System.ComponentModel.BackgroundWorker = _CType(sender, System.ComponentModel.BackgroundWorker)' Assign the result of the computation' to the Result property of the DoWorkEventArgs' object. This is will be available to the ' RunWorkerCompleted eventhandler.showProgress(worker)EndSubPrivateSub showProgress(ByVal worker As System.ComponentModel.BackgroundWorker)Dim progressForm AsNew TaskProgress()progressForm.Show()' Refresh causes an instant (non-posted) display of the label.progressForm.Refresh()' Slowly increment the progress bar.WhileNot worker.CancellationPendingIf progressForm.ProgressIndicator.Value = 100ThenprogressForm.ProgressIndicator.Value = 0ElseprogressForm.ProgressIndicator.Value += 10EndIf' 50 millisecond delaySystem.Threading.Thread.Sleep(50)EndWhileprogressForm.ProgressIndicator.MarqueeAnimationSpeed = 0' Remove the form after the "task" finishes.progressForm.Hide()progressForm.Dispose()EndSub#EndRegion