Two Silverlight Apps on same HTML page

This solution provides a training opportunity! I can now demonstrate why IsolatedStorage.SiteSettings are not good for passing data between running Silverlight applications.

Try the following little tests with these two applications and see if you can explain what is happening. I'll refer to the first app (the one with the green border) and the 2nd app (the one with the blue border):

  1. In the 2nd app, type in a small integer into the text box next to the Save Counter button
  2. Press the Save Counter button
  3. Verify the counter can be read by pressing the Fetch Counter button
  4. now refresh the page (click the browser's page refresh button). This will cause the two applications to exit, reload and reinitialize.
  5. Now in the 1st app, press the Site Counter button. Verify that the number displayed is the same as the number you entered in step 1 above.
Get Microsoft Silverlight
Get Microsoft Silverlight

Now lets look at some odd behavior...

  1. Repeat the first test again, but use a different number (and skip the page refresh step...step number 4). Does the number that you saved in the 2nd app show in the first app? Why?
  2.  Right mouse click either of these apps and delete all of the IsolatedStorage for Silverlight then press the browser page refresh button. Now do this test
    1. in the first app, press the Site Counter button (and you should see a message that the site counter is not yet been set...an expected result)
    2. in the second app, type in a number in the text box and press the Save Counter button. Press the 2nd app's Fetch Counter button to verify that you can read the number you saved.
    3. in the first app, press the Site Counter button...can you explain this result? Wait, it gets better....
    4. in the second app, press the Fetch Counter button.
    5. now press the browsers page refresh button (this will cause the two Silverlight apps to exit, and then reload)
    6. in the second app, press the Fetch Counter button. What happened and can you explain it?