Exercise 3: Verification

In this verification, you will run the application to verify that all the queries are shown in the main application. The Woodgrove manufacturer will be loaded from a different Silverlight package downloaded from the website.

  1. Compile the solution (CTRL+SHIFT+B).
  2. Expand the ClientBin folder under the ContosoAutomotive.Silverlight.Web project and verify that there are two Silverlight packages present.

    Figure 35

    Silverlight packages in the ContosoAutomotive.Silverlight.Web project (C#)

    Figure 36

    Silverlight packages in the ContosoAutomotive.Silverlight.Web project (Visual Basic)

  3. You will modify the way the application loads the Woodgrove package to emphasize the fact it is being downloaded from the website. Open the App class in the ContosoAutomotive.Silverlight project and modify the Application_Startup method including the bolded line of code below.

    (Code Snippet – Intro to MEF Lab - Ex3 Verification Step3 - DownloadCompleteAddHandler CSharp)

    C#

    private void Application_Startup(object sender, StartupEventArgs e)
    FakePre-f4b5179622d64c9eb1038c17fa36a998-1da4dd912a73453185da54ceda16f514FakePre-a63a2a7d677242b7ac48914cd7c24235-396d703630b64f5a98f4679b20b19a67FakePre-3eb8efba47804a11862d00cdf2d53008-45b03f8aeeb24733b0d18437781127eb xapCatalog.DownloadCompleted += new EventHandler<System.ComponentModel.AsyncCompletedEventArgs>(xapCatalog_DownloadCompleted);FakePre-fa6d5bf4797841f2aef3d05e00c2bced-dbd6061f3c5149b7b7493d55636c7fd1FakePre-fb36bcad9a404fdf97023ae23aa0eabc-a45974235ac24c3d8e2038760ab8abd8FakePre-1fdbeb6fa414435eac0a046238058e85-7e24a6caf3da4ceca3e38a0bdaba1debFakePre-2bdf71ea3a60469fbb750f58aba14d28-a0857488b1bd42f8b04cc3e698c87bc7FakePre-d2fbfb9c71334ad487bf410a589982c9-6d0d4934d8e940d6973a7a7c9cbbe53bFakePre-31a996e3f89946f89f758178639331fb-957cf3684c28406aac9f3d40b734266aFakePre-4d4f0bd0ca3e490d868dc051207258bf-3f364f886b8442f38a80277a03b35d6fFakePre-988cc1c5917c4d70824ba017412172e1-cc115dfca1834a76865a29530f9e5a62

    (Code Snippet – Intro to MEF Lab - Ex3 Verification Step3 - DownloadCompleteAddHandler VB)

    Visual Basic

    Private Sub Application_Startup(ByVal o As Object, ByVal e As StartupEventArgs) Handles Me.Startup
    FakePre-f7f9b0ad38f942f9a9c98135a181d0c7-9f85dfb887054c0fb4848e79185aea36FakePre-4d173f85bdb94b068ce2d78fdaa6c67a-bedf98dc4134432a82e5b939849f7cdb AddHandler xapCatalog.DownloadCompleted, AddressOf xapCatalog_DownloadCompletedFakePre-6d24d11342c347bca2b91521f120eced-fa7983b5ce4e41a6811cbf94cf77c8a1FakePre-429563f8e22d42ee82ed5feb01ad39ce-9970339362fc4e86a5488593ab594dcbFakePre-4ae215d20a104f21b5611340021fc2e9-dbd4e0ab4cc2416599448c7d5d816b98FakePre-a5d5da2f70aa47b09f403483b6f2cb78-2e737afbb31446f1b9087cda32206c54FakePre-a978b8f573ba4846bfff4436de4bc328-ebdb42e831264e3a8cdb2c7baa2fbe7aFakePre-8fe40dea5b86497eaeb0d64260985992-c4dfe631bf55475f85bb5adca48a2b11FakePre-ca35b5668bbb44d38c717c7d9d051ec8-509b76675c664e628b46ea82276a0975

  4. Add the xapCatalog_DownloadCompleted method handler to increment in two seconds the delay experienced by downloading a new package from internet. In the App class, add the following methods below the Application_Startup method.

    (Code Snippet – Intro to MEF Lab - Ex3 Verification Step4 - DownloadCompleteMethod CSharp)

    C#

    private void xapCatalog_DownloadCompleted(object sender, System.ComponentModel.AsyncCompletedEventArgs e) { System.Threading.Thread.Sleep(2000); }

    (Code Snippet – Intro to MEF Lab - Ex3 Verification Step4 - DownloadCompleteMethod VB)

    Visual Basic

    Private Sub xapCatalog_DownloadCompleted(ByVal sender As Object, ByVal e As System.ComponentModel.AsyncCompletedEventArgs) System.Threading.Thread.Sleep(2000) End Sub

  5. Set ContosoAutomotive.Silverlight.Web as the startup project. To do this, in the Solution Explorer, right-click ContosoAutomotive.Silverlight.Web and select Set as Startup Project.
  6. Press F5 to run the application. The CashMaker application should appear with a list of manufacturers on it. You should note that the Woodgrove manufacturer item would appear after some delay.

    Figure 37

    The CashMaker Silverlight application shows manufacturers.

  7. Close the browser by clicking on the close button ().

Next Step

Summary