What should you do?

You are updating a Windows desktop client application that was created by using Microsoft .NET Framework 4 and Microsoft Visual Studio 2010.
The application displays data derived from several database queries. The display takes a long time to update.
The application currently uses a BackgroundWorker thread and a Parallel.ForEach statement on that thread.
Users have requested a modification to the program that would allow them to interrupt the display of data and begin processing a new and different query.
You decide to provide a new Stop button on the user interface (UI) to allow the user to terminate the current data display and initiate the new query.
The main UI thread must be notified when the current data processing is terminated so that the new query can be started.
You need to implement the Stop button event handler.
What should you do?
A. . Use the DoWork handler of the worker thread and test a shared status value.
. Use a break statement to terminate the Parallel.ForEach loop.
B. . Use the DoWork handler of the worker thread and test a shared status value.
. Use a loopStatus.Stop() statement to terminate the Parallel.ForEach loop.
C. . Use the DoWork handler of the worker thread and test a shared status value.
. Use the Thread.AbortQ statement to terminate the worker thread.
. Start a new BackgroundWorker thread from the main UI thread.
D. . Use a CancelAsync() function to cancel the worker thread.
. In the Parallel.ForEach loop, test the CancellationPending property.
. If the property is set to true, perform the following tasks:
Write a loopStatus.Stop() statement.
Set the DoWorkEventArgs.Cancel property to true.
Use a return statement to exit from the loop.

microsoft-exams

Leave a Reply

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


The reCAPTCHA verification period has expired. Please reload the page.