You are customizing a Windows Form to update a database asynchronously by using an instance of a BackgroundWorker component named bgwExecute. You start the component by using the following code.
Private Sub StartBackgroundProcess()
AddHandler bgwExecute.DoWork, _
New DoWorkEventHandler(AddressOf WorkHandler)
AddHandler bgwExecute.RunWorkerCompleted, _
New RunWorkerCompletedEventHandler(AddressOf _
CompletedHandler)
AddHandler bgwExecute.ProgressChanged, _
New ProgressChangedEventHandler(AddressOf ProgressChanged) bgwExecute.RunWorkerAsync()
End Sub
If the UpdateDB method that is called by the BackgroundWorker component returns the value False, you need to display a message box to the user that indicates that the update failed. Which code segment should you use?
A.
Sub WorkHandler(ByVal sender As Object, ByVal e As DoWorkEventArgs) If Not UpdateDB() Then MessageBox.Show(“Update failed”) End IfEnd Sub
B.
Sub CompletedHandler(ByVal sender As Object, ByVal e As _ RunWorkerCompletedEventArgs) If Not UpdateDB() Then MessageBox.Show(“Update failed”) End IfEnd Sub
C.
Sub WorkHandler(ByVal sender As Object, ByVal e As DoWorkEventArgs) e.Result = UpdateDB()End
Sub Sub CompletedHandler(ByVal sender As Object, ByVal e As _ RunWorkerCompletedEventArgs) If Not CBool(e.Result) Then MessageBox.Show(“Update failed”) End IfEnd Sub
D.
Sub WorkHandler(ByVal sender As Object, ByVal e As DoWorkEventArgs) e.Result = UpdateDB()End Sub Sub CompletedHandler(ByVal sender As Object, ByVal e As _ RunWorkerCompletedEventArgs) If Not CBool(e.Result) Then bgwExecute.ReportProgress(0) End IfEnd Sub Sub ProgressChanged(ByVal sender As Object, ByVal e As _ ProgressChangedEventArgs) If e.ProgressPercentage = 0 Then MessageBox.Show(“Update failed”) End IfEnd Sub