views:

49

answers:

2

In a Windows Phone 7 application, I need to do some treatment before the first page gets opened.
But I'd like to do it during the splash screen, so the user knows the application is effectively running.

I tried several events :

  • Application.Launching event is fired before splash screen
  • Frame.Navigated event is fired after the first page is loaded

Is there any way to do something between those 2 events ?

+1  A: 

Perhaps using the technique outlined in this blog post ? http://blogs.msdn.com/b/priozersk/archive/2010/08/17/creating-a-splash-screen-with-a-progress-bar-for-wp7-applications.aspx

driis
This technique is a nice workaround, but it involves creating a "dummy" page to do some work, and then navigate to the actual first page. (the backgroundWorker_DoWork method is executed **after** the first page has been loaded)
Victor Bonnedun
A: 

The Windows Phone 7 application execution model allows you to perform various operations when the application is loading (as you mentioned - before the actual splash screen) and after the application is loaded (add activated and deactivated to that list as well). You cannot insert specific processes between application loading and loading completion - only on initialization and after it.

For more information, I'd recommend reading:

Understanding the Windows Phone Application Execution Model, Tombstoning, Launcher and Choosers, and Few More Things That Are on the Way – Part 1

Going further, it is not recommended to perform time and resource-consuming operations while the application is launching. According to MSDN:

Applications should not load state data from Isolated Storage in the handler for this event. 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 as the application will take a long time to load. Instead, calls to Isolated Storage and network resources should be performed asynchronously after the application has loaded.

It is not a restriction, but rather a recommendation that helps providing a better user experience. Therefore, you should carefully plan what you want to do on application startup.

Dennis Delimarsky