You are customizing a Windows Form to use a BackgroundWorker component named bgwExecute. bgwExecute perform a database operation by 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?
A.
public void StartBackground() {
bgwExecute.WorkerReportsProgress = true;
bgwExecute.ProgressChanged +=
new ProgressChangedEventHandler(ProgressHandler);
bgwExecute.Run WorkerAsync();
}
void WorkHandler(object sender, DoWorkEventArgs e) {
pbProgress.ReportProgress(50);
}
void ProgressHandler(object sender, ProgressChangedEventArgs e) {
pbProgress.Value = e.ProgressPercentage;
}
B.
public void StartBackground() {
bgwExecute.WorkerReporterProgress = true;
bgwExecute.ProgressChanged += new
ProgressChangedEventHandler(ProgressHandler);
ThreadStart t = new ThreadStart(WorkHandler);
bgwExecute.RunWorkerAsync(t);
}
void WorkHandler() {
bgwExecute.ReporterProgress(50);
}
void ProgressHandler(object sender, ProgressChangedEventArgs e) {
bgProgress.Value = e.ProgressPercentage;
}
C.
public void StartBackground() {
bgwExecute.WorkerReporterProgress = true;
bgwExecute.ProgressChanged += new
ProgressChangedEventHandler(ProgressHandler);
Thread t = new Thread(new ThreadStart(WorkHandler));
bgwExecute.RunWorkerAsync(t);
}
void WorkHandler() {
bgwExecute.ReporterProgress(50);
}
void ProgressHandler(object sender, ProgressChangedEventArgs e) {
bgProgress.Value = e.ProgressPercentage;
}
D.
public void StartBackground() {
bgwExecute.WorkerReportsProgress = true;
bgwExecute.DoWork += new Do WorkEventHandler(WorkHandler);
bgwExecute.ProgressChanged += new
ProgressChangedEventHandler(ProgressHandler);
bgwExecute.RunWorkerAsync();}
void WorkHandler(object sender, DoWorkEventArgs e)
{ bgwExecute.ReporterProgress(50);}
void ProgressHandler(object sender, ProgressChangedEventArgs e) {
pbProgress.Value =e.ProgressPercentage:}