What should you do to make sure that the event handler gets called?

You are busy using a BackgroundWorker component to execute an asynchronous operation. The job of the background thread is to call the ReportProgress method to update the foreground thread. You have handled the ProgressChanged event and set the Value property of a ProgressBar. The problem is that the ProgressBar display by no means gets updated. During the investigation you find out t6hatvthe event handler that works with the ProgressChanged event never gets called. What should you do to make sure that the event handler gets called?

You are busy using a BackgroundWorker component to execute an asynchronous operation. The job of the background thread is to call the ReportProgress method to update the foreground thread. You have handled the ProgressChanged event and set the Value property of a ProgressBar. The problem is that the ProgressBar display by no means gets updated. During the investigation you find out t6hatvthe event handler that works with the ProgressChanged event never gets called. What should you do to make sure that the event handler gets called?

A.
You should call the ReportProgress method in the foreground thread.

B.
You should set the WorkerReportsProgress property to True.

C.
You should set the BackgroundWorker component to the value of the Site property returned from the ProgressBar control.

D.
You should set the BackgroundWorker component to the value of the Site property returned from Form control that host the component.

Explanation:
The WorkerReportsProgress property shows whether the BackgroundWorker component should raise the ProgressChanged event when the backgroung thread calls the ReportProgress method.

Incorrect Answers:
A: The BackgroundWorker should call the ReportProgress. You should not put it to the foreground.
C, D: The Site property should not be changed. It defined the binding between a control or component and its associate container.
C: Cancel a background process by using the BackgroundWorker component.
D: Report the progress of a background process by using the BackgroundWorker component.



Leave a Reply 0

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