What should you do to configure the BackgroundWorker component appropriately to prevent the application?

You are creating a Windows application by using the .NET Framework 3.5.
The Windows application has print functionality. You create an instance of a BackgroundWorker component named backgroundWorker1.
You discover that when the application attempts to cancel the background process, you receive a System.InvalidOperationException exception on the following code segment:

backgroundWorker1.CancelAsync();

You need to configure the BackgroundWorker component appropriately to prevent the application from generating exceptions.
What should you do?

You are creating a Windows application by using the .NET Framework 3.5.
The Windows application has print functionality. You create an instance of a BackgroundWorker component named backgroundWorker1.
You discover that when the application attempts to cancel the background process, you receive a System.InvalidOperationException exception on the following code segment:

backgroundWorker1.CancelAsync();

You need to configure the BackgroundWorker component appropriately to prevent the application from generating exceptions.
What should you do?

A.
Cancel the background process in the backgroundWorker1_DoWork event.

B.
Set the IsBusy property of backgroundWorker1 to True before you attempt to cancel the progress.

C.
Set the WorkerSupportsCancellation property of backgroundWorker1 to True before you attempt to cancel the progress.

D.
Set the DoWorkEventArgs Cancel property to True in the backgroundWorker1_DoWork event handler before you attempt to cancel the background process.



Leave a Reply 0

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