Implement Asynchronous Programming Techniques to Improve the User Experience

These questions are based on 70-526VB: TS: Microsoft .NET Framework 2.0 – Windows-Based Client Development (VB.NET)
Self Test Software Practice Test

Objective: Implement asynchronous programming techniques to improve the user experience.
Sub-objective: Manage a background process by using the BackgroundWorker component.

Single answer, multiple-choice

You are an application developer for a company. You are creating a Windows application that will be used by employees of the Sales and Marketing departments to generate regional monthly sales reports. The sales data is stored in a Microsoft SQL Server 2005 database named Sales. The total number of records to be retrieved from the Sales database is displayed using a function named FetchMonthData. The FetchMonthData function accepts an argument named m_Month of Integer type. Users will specify the m_Month value using a TextBox control named txtMonth.

When your application is deployed in your production environment, users complain that reports using the FetchMonthData function take a long time to display and that the UI hangs.

You decide to execute the FetchMonthData asynchronously and add a BackgroundWorker component named BackgroundWorker1. You then add the following code to start the asynchronous operation:

Private Sub btnDisplayReport_Click(ByVal sender As System.Object, _
 ByVal e As System.EventArgs)Handles btnDisplayReport.Click
End Sub

Private Sub backgroundWorker1_DoWork(ByVal sender As Object, _
 ByVal e As DoWorkEventArgs)Handles BackgroundWorker1.DoWork
 Dim myWork As BackgroundWorker = CType(sender, BackgroundWorker)
 e.Result = FetchMonthData(e.Argument, myWork, e)
End Sub

You must display the result of FetchMonthData in a Label control named lblCount.

Which code should you use?



Posted in Uncategorized|


Powered by WebDesk