1 / 24

Offline Detection in SL 3 and .NET Framework

Offline Detection in SL 3 and .NET Framework. Peter Smith Program Manager, .NET Networking Microsoft Corporation. Why Offline Detection?. Silverlight now has the ability to run from the user’s desktop, just like a normal application

aquarius
Download Presentation

Offline Detection in SL 3 and .NET Framework

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Offline Detection in SL 3 and .NET Framework Peter Smith Program Manager, .NET Networking Microsoft Corporation

  2. Why Offline Detection? • Silverlight now has the ability to run from the user’s desktop, just like a normal application • Sometimes when your code runs, the user will not be online • You have to detect and handle this case

  3. The One Take-Away Point • How do you know if you are online? • Can you connect to your server? • Have you validated the response? • Microsoft can help by telling you when to try again

  4. demo Demonstration A very simple Silverlight 3 application that does network detection

  5. Why Offline is So Hard • Is the network useful? • Driver issues • Virtual PCs! • Coffee shop problem • Maybe you shouldn’t connect!

  6. The One Take-Away Point • How do you know if you are online? • Can you connect to your server? • Have you validated the response? • Microsoft can help by telling you when to try again

  7. VB.NET Sample • REM function that gets called when the network changes • PrivateSubOnNetworkChange (ByVal s AsObject, _ • ByVal a AsEventArgs) • REM Perform detection here • EndSub • REM set up the system to call that function • PublicSubNew() • AddHandlerNetworkInformation. _ • NetworkChange.NetworkAddressChanged, _ • AddressOfOnNetworkChange • EndSub

  8. C# Sample • privatevoidOnNetworkChange (Object sender, EventArgsArgs) • { • // Put network detection here • } • publicMainPage() • { • NetworkChange.NetworkAddressChanged += • newNetworkAddressChangedEventHandler • (OnNetworkChange); • }

  9. Patterns For Your Code • Ask the user • Before you connect, validate • Constantly validate results

  10. Ask the User • Add two buttons to your application • One is “retry” and tries to connect again • The other is “offline mode” and prevents the application from even trying

  11. Before You Connect, Validate • Put a standard file on your server • Download and check contents • No server==really offline • Revalidate on network change • Got a file from your server, but it’s not yours? You might be have the “coffee shop” problem and must retry

  12. Constantly Check Results • Check all downloads • Not just status code! • No server==really offline • Revalidate on network change • Got a file from your server, but it’s not yours? You might be have the “coffee shop” problem and must retry

  13. The One Take-Away Point • How do you know if you are online? • Can you connect to your server? • Have you validated the response? • Microsoft can help by telling you when to try again

  14. Thank you! Questions? My email is pesmith@microsoft.com NCL (System.Net) blog is http://blogs.msdn.com/ncl/ The team forum is http://social.msdn.microsoft.com/Forums/en-US/ncl/threads/

  15. Please Complete an Evaluation FormYour feedback is important! • Evaluation forms can be found on each chair • Temp Staff at the back of the room have additional evaluation form copies

  16. © 2009 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

  17. Extra Slides! These slides go into more detail about the advantages and disadvantages of the different code patterns for network detection

  18. Advantages of Ask the User • The user might know that they’ve done something special (but undetectable) to go on line • The user might also know that it’s a bad time to go online

  19. Disadvantages to Ask the User • The user might not know that they’ve gone online (and get it wrong) • They also probably think it’s your job normally

  20. Advantages of the Before Pattern • It’s simple • You only have to understand one file (and you can just make it XML)

  21. Disadvantages of "Before" • It’s not always possible to drop a file on your company server • It has an extra bit of work at startup • Sometimes the network changes, but you don’t detect it in time (and ruin a downloaded file)

  22. Advantages of Constantly Check • Starts up faster – no extra file to download • Requires no changes to your server

  23. Disadvantages to Constantly Check • Checking is hard! You have to understand all of the different file types that your application might have • Checking is “noisy”: there are lots of reasons why your server might not have given a good reply

More Related