Which code segment is used to display a message box to alert the users when the background thread is complete?

You are busy using a BackgroundWorker component to call a method named DownloadJob in a background thread.
Which code segment is used to display a message box to alert the users when the background thread is complete?

You are busy using a BackgroundWorker component to call a method named DownloadJob in a background thread.
Which code segment is used to display a message box to alert the users when the background thread is complete?

A.
if[backgroundWorker.Worker.WorkerReportsProgress ==false] {
MessageBox.Show["The download is complete."];
}

B.
backgroundWorker.DoWork +=delegate
{
MessageBox.Show["The download is complete."];
}

C.
if [backgroundWorker.IsBusy==false]
{
MessageBox.Show["The download is complete."];
}

D.
backgroundWorker.RunWorkerCompleted += delegate
{
MessageBox.Show["The download is complete."];
}

Explanation:
The BackgroundWorker allow you to perform task in a background thread. The BackgroundWorker class has a method called RunWorkerAsync that raises a DoWork event.

Incorrect Answers:
A: The message only, should not be displayed. This shows whether the BackgroundWorker should raise the ProgressChange event when the background thread calls the ReportProgress method.
B: The DoWork does not display the message. It raises the background thread to start.
C: The IsBusyshows whether the background threads are busy.



Leave a Reply 0

Your email address will not be published. Required fields are marked *