You are customizing a Windows Form to asynchronously update a database. You need to ensure that the form display a message box to the user that indicates the success or failure of the update. Which three code segment should you use? (Each correct answer presents part of the solution. Choose three.)
A.
private void StartBackGroundProcess() {
bgwExecute.DoWork += new Do WorkEventHandler(WorkHandler);
bgwExecute.RunWorkerCompleted +=
new RunWorkerCompletedEventHandler(CompletedHandler);
bgwExecute.RunWorkerAsync();
}
B.
private void StartBackgroundProcess() {
bgwExecute.ProcessChanged +=
newProgressChangedEventHandler(CompeletedHandler);
ThreadStart tsBackground = new ThreadStart(WorkHandler);
bgwExecute.RunEorkAsync(tsBackground);
}
C.
private void StartBackgroundProcess() {
bgwExecute.RunWorkerCompleted +=
new RunWorkerCompletedEventHandler(CompletedHandler);
ThreadStart tsBackground = new ThreadStart(WorkHandler);
bgwExecute.RunEorkAsync(tsBackground);
}
D.
void WorkHandler(object sender, DoWorkEventArgs e) { // …
Result=true;
}
E.
void WorkHandler(object sender, DoWorkEventsArgs e) { // …
bgwExecute.ReportProgress(100, true);
}
F.
void CompletedHandler(object sender, RunWorkerCompletedEventArgs e) {
bool result = (bool)e.Result;
MessageBox.Show("Update " + (result ? "was successful" : "failed"));
}
G.
void ProgressHandler(object sender, ProgressChangeEventArgs e) {
bool result = (bool)e.UserState;
MessageBox.Show("Update " + (result ? "was successful" : "failed"));
}