PrepAway - Latest Free Exam Questions & Answers

Author: seenagape

Which code segment should you use to replace line 11?

You are developing an application by using Silverlight 4 and Microsoft .NET Framework 4. You add a BackgroundWorker object named worker to the application.
You add the following code segment. (Line numbers are included for reference only.)

01 public MainPage()
02 {
03 InitializeComponent();
04 worker.WorkerSupportsCancellation = true;
05 worker.DoWork += new DoWorkEventHandler(worker_DoWork);
06 worker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(worker_Completed)
07 }
08 private void worker_DoWork(object sender, DoWorkEventArgs e)
09 {
10 for (int i = 0; i < 100; i++) {
11 InvokeLongRunningProcessStep();
12 }
13 }

You need to ensure that worker can be properly canceled. Which code segment should you use to replace line 11?

Which two actions should you perform?

You are developing an application by using Silverlight 4 and Microsoft .NET Framework 4.
You create a Windows Communication Foundation (WCF) Data Service. You add a service reference to the WCF Data Service named NorthwindEntities in the Silverlight application. You also add a CollectionViewSource object named ordersViewSource in the Silverlight application.
You add the following code segment. (Line numbers are included for reference only.)

01 void getOrders_Click(object sender, RoutedEventArgs e)
02 {
03 var context = new NorthwindEntities();
04
05 var query = from order in context.Orders
06 select order;
07
08 }

You need to retrieve the Orders data from the WCF Data Service and bind the data to the ordersViewSource object. Which two actions should you perform?
(Each correct answer presents part of the solution. Choose two.)

Which code segment should you replace at lines 02 and 03?

You are developing an application by using Silverlight 4 and Microsoft .NET Framework 4. The application contains the following XAML fragment.
<TextBlock x:Name=”QuoteOfTheDay” />
The application calls a Windows Communication Foundation (WCF) service named MyService that returns the quote of the day and assigns it to the QuoteOfTheDay TextBlock.
The application contains the following code segment. (Line numbers are included for reference only.)

01 var client = new MyService.MyServiceClient();
02 client.GetQuoteOfTheDayCompleted += (s, args) => QuoteOfTheDay.Text = args.Result;
03 client.GetQuoteOfTheDayAsync();

You need to handle errors that might occur as a result of the service call. You also need to provide a default value of “Unavailable” when an error occurs.
Which code segment should you replace at lines 02 and 03?

Which code segment should you add at line 03?

You are developing an application by using Silverlight 4 and Microsoft .NET Framework 4. You create a new user control in the application. You add the following XAML fragment
to the control:

<StackPanel KeyDown=”App_KeyDown” Orientation=”Vertical”>
<TextBox x:Name=”firstName” />
<TextBox x:Name=”lastName” />
<TextBox x:Name=”address” />
</StackPanel>

You add the following code segment in the code behind file of the control. (Line numbers are included for reference only.)

01 private void App_KeyDown(object sender, KeyEventArgs e)
02 {
03
04 }
05
06 private void FirstAndLastNameKeyDown()
07 {
08 …
09 }

You need to ensure that the First And LastName KeyDown method is invoked when a key is pressed while the focus is on the firstName or lastName TextBox controls. You also need to ensure that the default behavior of the controls remains unchanged.
Which code segment should you add at line 03?