nerdexam
Microsoft

70-518 · Question #121

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…

The correct answer is D. ?Use a CancelAsync() function to cancel the worker thread. See the full explanation below for the reasoning.

Question

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?

Options

  • AUse the DoWork handler of the worker thread and test a shared status value.
  • BUse the DoWork handler of the worker thread and test a shared status value.
  • CUse the DoWork handler of the worker thread and test a shared status value.
  • D?Use a CancelAsync() function to cancel the worker thread.

How the community answered

(37 responses)
  • A
    3% (1)
  • B
    8% (3)
  • C
    16% (6)
  • D
    73% (27)

Community Discussion

No community discussion yet for this question.

Full 70-518 Practice