nerdexam
Microsoft

70-518 · Question #59

You are analyzing a Windows client application that uses Microsoft Visual Studio 2010 and Microsoft SQL Server 2008. The application updates two database tables from the main user interface (UI)…

The correct answer is B. Move the database update logic to a BackgroundWorker thread. We need a background worker process => A out. Users are able to perform other tasks during the update process. => Users are notified of the success or failure of the updates. => yes for B,C,D ( whether because the process is completed or because the process is cancelled, the…

Developing Data Access

Question

You are analyzing a Windows client application that uses Microsoft Visual Studio 2010 and Microsoft SQL Server 2008. The application updates two database tables from the main user interface (UI) thread. You need to ensure that the following requirements are met:

The database tables are either updated simultaneously or not updated at all. Users are notified of the success or failure of the updates. Users are able to perform other tasks during the update process. What should you do?

Options

  • AUse TransactionScope in a using block on the UI thread.
  • BMove the database update logic to a BackgroundWorker thread.
  • CUse TransactionScope in a using block on the main thread.
  • DUse TransactionScope in a using block on the UI thread.

How the community answered

(36 responses)
  • A
    3% (1)
  • B
    78% (28)
  • C
    14% (5)
  • D
    6% (2)

Explanation

We need a background worker process => A out. Users are able to perform other tasks during the update process. => Users are notified of the success or failure of the updates. => yes for B,C,D ( whether because the process is completed or because the process is cancelled, the RunWorkerCompleted event is The DependentTransaction is a clone of a Transaction object created using the DependentClone Its sole purpose is to allow the application to come to rest and guarantee that the transaction cannot commit while work is still being performed on the transaction (for example, on a worker thread). => Users are able to perform other tasks during the update process => D out B,C => still left => DoWork event handler is used for a worker thread => B correct The code in the DoWork event handler is executed on a separate, dedicated thread, allowing the UI to remain private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e) for (int i = 1;i < 11; i++) RunTimeConsumingProcess(); // Calls the Report Progress method, indicating the percentage // complete backgroundWorker1.ReportProgress(i*10);

Topics

#TransactionScope#BackgroundWorker#UI threading#atomic updates

Community Discussion

No community discussion yet for this question.

Full 70-518 Practice