locked
Calling LoadAsync() on ten different IsolatedStorageOfflineContext freezes App RRS feed

  • Question

  • In my application i have ten different IsolatedStorageOfflineContext. I am calling LoadAsync() on all of them from the Application_Launching event.

    In most cases this freezes the App at built-in splash screen. In this situation the VisualStudio debug session stalls until i kill the emulator or disconnect the physical device. If attempted on a physical device it has to be hard-resetted by removing the battery.

    In some cases unhandled System.TypeLoadException for System.Runtime.InteropServices.SEHException is thrown instead of freezing the app.

    In rare cases (maybe 1 out of 8) the application actually launches but feels very sluggish until all contexts have finished loading. When the application is exited (with the back button) before all contexts have finished loading, again System.TypeLoadException for System.Runtime.InteropServices.SEHException is thrown.

    Thursday, November 18, 2010 2:49 PM

Answers

  • The recommended way to do this would be to do it on a Page loaded event. Why are you doing this on Application_Launching? The behavior is weird as your app hasnt completely loaded all its resources by that time. Recommendation is have a landing page that just shows a "Loading" progress bar and load the contexts on that page's Loaded event handler.


    Maheshwar Jayaraman - http://blogs.msdn.com/mahjayar
    Thursday, November 18, 2010 7:17 PM

All replies

  • The recommended way to do this would be to do it on a Page loaded event. Why are you doing this on Application_Launching? The behavior is weird as your app hasnt completely loaded all its resources by that time. Recommendation is have a landing page that just shows a "Loading" progress bar and load the contexts on that page's Loaded event handler.


    Maheshwar Jayaraman - http://blogs.msdn.com/mahjayar
    Thursday, November 18, 2010 7:17 PM
  • The recommended way to do this would be to do it on a Page loaded event. Why are you doing this on Application_Launching?

    I just thought this to be best practices because in the official Windows Phone 7 Training Course Exercise 1: Introducing the Windows Phone Application Life Cycle i have learned:

    When the application is started, the Launching event is raised. In the handler for this event, an application should read any necessary data from isolated storage to present the user with a new application session.

    And in the MSDN article Execution Model Overview for Windows Phone it says:

    Launching - [...] Because this event is raised before the application is visible or active, performing time consuming tasks, like accessing Isolated Storage can provide a bad user experience [...] Instead, calls to Isolated Storage and network resources should be performed asynchronously after the application has loaded.
    Friday, November 19, 2010 8:37 AM