PrepAway - Latest Free Exam Questions & Answers

Which code segment should you use?

You are customizing a Windows Form to use a BackgroundWorker component named bgwExecute. bgwExecute performs a database operation in an event handler named WorkHandler. You need to ensure that users can see the progress of the database operation by viewing a
progress bar named pbProgress. You want the progress bar to appear when the database operation is 50 percent complete. Which code segment should you use?

PrepAway - Latest Free Exam Questions & Answers

A.
Public Sub StartBackground() bgwExecute.WorkerReportsProgress = True AddHandler bgwExecute.ProgressChanged, AddressOf ProgressHandler bgwExecute.RunWorkerAsync()End Sub Sub WorkHandler(ByVal sender As Object, ByVal e As DoWorkEventArgs) bgwExecute.ReportProgress(50)End Sub Sub ProgressHandler(ByVal sender As Object, ByVal e As _ ProgressChangedEventArgs) pbProgress.Value = e.ProgressPercentageEnd Sub

B.
Public Sub StartBackground() bgwExecute.WorkerReportsProgress = True AddHandler bgwExecute.ProgressChanged, AddressOf ProgressHandler Dim t As New ThreadStart(AddressOf WorkHandler) bgwExecute.RunWorkerAsync(t)End Sub Sub WorkHandler() bgwExecute.ReportProgress(50)End Sub Sub ProgressHandler(ByVal sender As Object, ByVal e As _ ProgressChangedEventArgs) pbProgress.Value = e.ProgressPercentageEnd Sub

C.
Public Sub StartBackground() bgwExecute.WorkerReportsProgress = True AddHandler bgwExecute.ProgressChanged, AddressOf ProgressHandler Dim t As New Thread(New ThreadStart(AddressOf WorkHandler)) bgwExecute.RunWorkerAsync(t)End Sub Sub WorkHandler() bgwExecute.ReportProgress(50)End Sub Sub ProgressHandler(ByVal sender As Object, ByVal e As _ ProgressChangedEventArgs) pbProgress.Value = e.ProgressPercentageEnd Sub

D.
Public Sub StartBackground() bgwExecute.WorkerReportsProgress = True AddHandler bgwExecute.DoWork, AddressOf WorkHandler AddHandler bgwExecute.ProgressChanged, AddressOf ProgressHandler bgwExecute.RunWorkerAsync()End Sub Sub WorkHandler(ByVal sender As Object, ByVal e As DoWorkEventArgs) bgwExecute.ReportProgress(50)End Sub Sub ProgressHandler(ByVal sender As Object, ByVal e As _ ProgressChangedEventArgs) pbProgress.Value = e.ProgressPercentageEnd Sub


Leave a Reply