在我的主窗体中,当我单击提交按钮时,将执行长时间运行的进程(5 个方法)。那时,我只想用 5 个交叉图像显示个人形式。在方法一一完成时,我想将交叉图像更改为刻度图像。我尝试了如下代码:
Private Sub btnRetrieve_Click(sender As System.Object, e As System.EventArgs) Handles btnRetrieve.Click
>
Try
If Not BackgroundWorker1.IsBusy Then
BackgroundWorker1.RunWorkerAsync()
End If
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
End Sub
Private Sub BackgroundWorker1_DoWork(sender As System.Object, e As System.ComponentModel.DoWorkEventArgs) Handles BackgroundWorker1.DoWork
Try
Retrieve()
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
End Sub
Public Sub Retrieve()
Try
RetrieveForm.Show()
Dim thrd1 As New Thread(New ThreadStart(AddressOf RetrieveClient))
Dim thrd2 As New Thread(New ThreadStart(AddressOf RetrieveProject))
Dim thrd3 As New Thread(New ThreadStart(AddressOf RetrieveModule))
Dim thrd4 As New Thread(New ThreadStart(AddressOf RetrievePerson))
Dim thrd5 As New Thread(New ThreadStart(AddressOf RetrieveStatus))
Dim thrd6 As New Thread(New ThreadStart(AddressOf RetrievePriority))
thrd1.Start()
tickimage(RetrieveForm.pbClient)
thrd2.Start()
tickimage(RetrieveForm.pbProject)
thrd3.Start()
tickimage(RetrieveForm.pbModule)
thrd4.Start()
tickimage(RetrieveForm.pbUsers)
thrd5.Start()
tickimage(RetrieveForm.pbStatus)
thrd6.Start()
tickimage(RetrieveForm.pbPriority)
Application.DoEvents()
MessageBox.Show("Retrieved")
RetrieveForm.Close()
InitialLoad()
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
End Sub
Public Sub tickimage(ByVal pbId As PictureBox)
Try
pbId.InitialImage = Nothing
Dim img As Image = Resources.tick1
pbId.Image = img
pbId.SizeMode = PictureBoxSizeMode.StretchImage
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
End Sub`
在这段代码中,当我第一次单击按钮时,所有图像都会打勾。我想在每种方法的末尾将图像从交叉更改为逐个打勾。我不知道我的代码有什么问题。如果有人发现其中有任何错误,请纠正我。