PrepAway - Latest Free Exam Questions & Answers

What should you do?

You are creating a Windows application by using the .NET Framework 3.5. You add a BackgroundWorker component to a Windows form to handle a time-consuming operation. You add a Cancel button to the form. You need to ensure that when the Cancel button is pressed, the background task is cancelled. What should you do?

PrepAway - Latest Free Exam Questions & Answers

A.
Set the DoWorkEventArgs.Cancel property to False in the DoWork event handler of BackgroundWorker.

B.
Call the BackgroundWorker.CancelAsync() method from the OnClick event handler of the Cancel button.

C.
Call the BackgroundWorker.CancelAsync() method from the DoWork event handler of the BackgroundWorker.

D.
Stop the process in the OnClick event handler of the Cancel button if the BackgroundWorker.CancellationPending property is True.


Leave a Reply