none
Extended Splash Screen Causing Black Screen If No Delay between setting Window.Current.Content

    Question

  • Hi all,

    I am trying to add an extended splash screen to my application so I can test the users internet connection and wait to retrieve an XML data source.  I have gone through the splash screen sample and recreated my own based on a Blank project which I linked to here:

    https://skydrive.live.com/redir?resid=38C1C5B2BBCE0152!1920&authkey=!AHx71J4LXM79oUE

    If you notice in my project I accidentally forgot to rename the added page so my ExtendedSplash page is actually BlankPage1.  Also, my BlankPage1 is a Page control instead of the base class UserControl which is used in the example.  These differences should not affect the app though.

    If you run the project it should build and work very similar to the splash screen sample.  You see the splash screen page load, then the extended splash screen (BlankPage1) with a progress circle, and if you click the "Continue" button you go to the actual "BlankPage" which would be the main app content.

    The problem is that I do not want the user to have to click a button to continue to the main content.  If you look at Line 64 in App.xaml.cs you see I have commented out some lines which I have previously tried.  If you uncomment these, the application builds fine, but when you run it, both the extended splash screen and the blank page do not load properly. It just stalls on a black screen.

    The idea is that I want to load the extended splash page, do some processing to get my XML datasource loaded and when that is finished populate the frame with the Grouped Items page, and then set the Frame as the current item in the window.  However, it seems there is some conflict when trying to set the Window.Current.Content without some delay in between calls.  The reason I say this is because I have seen other apps which automatically naviate from extended splash screens to grouped items pages without using a button click.  The only noticeable difference I see in their applications is that they have an await statement on their HttpClient method which pulls down a bunch of XML and introduces delay before the next attempt to set Window.Current.Content.  I have read some documentation about waiting for application activation and deferrals here:

    http://msdn.microsoft.com/library/windows/apps/Hh700390

    "Tip  If you use fragment loading to load your imitation splash screen page, you may notice a flicker between when the Windows splash screen is dismissed and when your page is displayed. You see this flicker because fragment loading begins to load your imitation splash screen page asynchronously, before the activated event handler finishes executing. You can avoid this unsightly flicker entirely by avoiding the use of fragment loading in your imitation splash screen page. When your additional loading tasks are complete (as demonstrated by the Splash screen sample) you can then navigate to your app’s main page. Alternatively, if you wish to continue the use of fragment loading in your imitation splash screen page, you can also prevent the flicker by getting a deferral and responding to activated events asynchronously. Get a deferral for an activated event by calling the  activatedOperation.getDeferral method."

    These both describe methods to eliminate flicker but I still didn't understand what "fragment loading" is or how it applies in my case so I disregarded it because I think I have bigger issues than flicker.  I'm just trying to get my extended splash screen to load. 

     

    I tried adding a DispatcherTimer with a 5 second interval with a Tick method which stopped the timer and called the second Window.Current.Content statement in order to simulate delay, but it had no affect. Still black screen.  

    I have 5 questions out of this problem:

    1. What is causing the black screen?  I assume it has to do with two asynchronous calls trying to change the Window.Current.Content but that's just a guess.

    2. Why does putting the second Window.Current.Content in an on click handler solve all the problems?

    3. What is fragment loading?

    4. If you call Window.Current.Activate() after you set the extended splash screen does it need to be called again?

    5. Is there anyone with moderator powers who can suggest to Microsoft to update the splash sample if we find a good solution?  It would seem to me that no one wants the user to have to click a button to "continue" an app they already wanted to start.  The extended splash screen is only to give more time for setup and not bother the user with buttons.

    Help is appreciated,

    - Matt

    Monday, June 04, 2012 5:20 AM

Answers

  • I did this in the Page.Loaded method and it automatically navigated when the WaitTenSeconds function was complete.

    private async void ExtendedSplashPage2_Loaded_1(object sender, RoutedEventArgs e)
            {
                Action MyAction = Wait10Seconds;
                await Task.Run(MyAction);
                Frame.Navigate(typeof(GroupedItemsPage), "AllGroups");
            }
            private async void Wait10Seconds()
            {
                await Task.Delay(TimeSpan.FromSeconds(10));
            }


    Matt Small - Microsoft Escalation Engineer - Forum Moderator
    If my reply answers your question, please mark this post as answered.

    Monday, June 11, 2012 4:32 PM

All replies

  • Hi Matt - I'll take a look at this and update you when I can.

    Matt Small - Microsoft Escalation Engineer - Forum Moderator
    If my reply answers your question, please mark this post as answered.

    Monday, June 04, 2012 10:39 PM
  • Hi,

    Ok, I downloaded the Release Preview and since the code has changed so much, it seems my old project is irrelevant.  I've recreated an extended splash screen project using updated code and here is a link:

    http://sdrv.ms/KBqqmm

    The project builds and works but still doesn't have the automated navigation.  In order to navigate to the actual start page (GroupedItemsPage) the user is still required to click a button.  For now, I think it would be better to just take this working project and figure out the best way to automate navigation to the GroupedItemsPage after some async call finishes ( It will end up being my HttpClient but I want to abstract that issue out for now ).

    If someone is still interested and wants to investigate what issues were occurring earlier, that would be great, but considering the code base will likely change again when RTM hits, I'd rather not worry about solving issue that were depending on an old coding style.

    - Matt

    Tuesday, June 05, 2012 3:22 PM
  • I did this in the Page.Loaded method and it automatically navigated when the WaitTenSeconds function was complete.

    private async void ExtendedSplashPage2_Loaded_1(object sender, RoutedEventArgs e)
            {
                Action MyAction = Wait10Seconds;
                await Task.Run(MyAction);
                Frame.Navigate(typeof(GroupedItemsPage), "AllGroups");
            }
            private async void Wait10Seconds()
            {
                await Task.Delay(TimeSpan.FromSeconds(10));
            }


    Matt Small - Microsoft Escalation Engineer - Forum Moderator
    If my reply answers your question, please mark this post as answered.

    Monday, June 11, 2012 4:32 PM
  • The solution given above works, but introduces a problem with navigation which I have created a new post for here:

    http://social.msdn.microsoft.com/Forums/en-US/winappswithcsharp/thread/ce818798-6395-483b-9f7f-3e31273e832d

    Monday, June 11, 2012 8:42 PM
  • @Matt - I'm trying to take the SplashScreen Example and modify it with your sample above to simply dismiss the splash screen after 10 seconds.  I'm not understanding how to wire up the ExtendedSplash2_Loaded_1 event handler.  My ultimate goal is to use an extended splash screen while my app is deserializing it's XML data so when the data is done being loaded, I can programmatically go to my main page without using a button click as shown in the SplashScreen example.

    Wednesday, September 26, 2012 7:39 PM