Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6205663
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T05:18:52+00:00 2026-05-24T05:18:52+00:00

As part of my App’s startup procedure, it checks data integrity, and if it

  • 0

As part of my App’s startup procedure, it checks data integrity, and if it finds a problem it pops up a message to the user telling them that it might take a while to repair things.

I’m showing the message using MessageBox.Show. Because the data check is done from a worker thread, I’m switching over to the UI thread to make that call, and then setting a ManualResetEvent to tell the worker thread when the user has acknowledged the message.

I kick off the data check/load very early in the app’s lifecycle from the constructor in the main Application class, by spinning off a worker thread (using the ThreadPool).

When I run with the debugger, and the message is displayed, the app just waits for input. When I run without the debugger, the app terminates after displaying the dialog for 10 seconds.

That 10 seconds is a big clue – it tells me that the OS thinks the app took too long to initialize (the OS kills apps that take too long to start up).

I think that my MessageBox.Show is blocking the UI thread before the App.RootFrameNavigating has a chance to be invoked.

My questions:

  • Does my diagnosis sound right?
  • I’d prefer to kick off my data load early, because it is almost entirely IO, except for this Message Box, and the sooner I can get my Model loaded, the better, but do you normally delay your data load until later in the app lifecycle?
  • Any other ideas/suggestions? I can’t guarantee which page will be the start page, because the app could be resuming to any page. I’m also thinking of having the MessageBox.Show delay itself until the app has initialized, perhaps polling away for a flag set by App.RootFrameNavigating – does that make sense?
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T05:18:52+00:00Added an answer on May 24, 2026 at 5:18 am

    So, the solution I’ve come up with is to still kick off the data load in a worker-thread from the Application’s constructor, but in my PhoneService’s class ShowDialog method that I invoke to invoke MessageBox.Show, I check to see if the initial navigation has occurred:

    private readonly ManualResetEvent _appInitialized = new ManualResetEvent(false);
    
    public void AppInitialized()
    {
        _appInitialized.Set();
    }
    
    
    public void ShowDialog(string caption, string text, Action<MessageBoxResult> callback, MessageBoxButton button = MessageBoxButton.OKCancel)
    {
        _appInitialized.WaitOne();
        DispatcherHelper.CheckBeginInvokeOnUI(() =>
        {
            var result = MessageBox.Show(text, caption, button);
    
            if (callback != null)
            {
                callback(result);
            }
        });
    }
    

    Then in my Application class:

    private bool _firstNavigate = true;
    private void RootFrameNavigating(object sender, NavigatingCancelEventArgs e)
    {
        if (_firstNavigate)
        {
            _firstNavigate = false;
            var navigationService = (NavigationService) sender;
            navigationService.Navigated += NavigationServiceNavigated;
        }
             ....
    
    
    private void NavigationServiceNavigated(object sender, NavigationEventArgs e)
    {
        var navigationService = (NavigationService)sender;
        navigationService.Navigated -= NavigationServiceNavigated;
        PhoneServices.Current.AppInitialized();
    }
    

    Anyone see any issues with this approach? Anyone come up with a better way?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

As part of our app, user can save some data as XML on server
I like to split my app.config into a user specific part and an application
Part of my app is responsible for writing to a feed all the user
My program, finds any subwindows, the case if an 3-part app shows an Error
Part of my app downloads images from the Internet and stores them in a
I've got a part in my app where the user can view some notes
I've been developing my first iPhone app part-time and would like to start using
Part of my app caches web pages for offline viewing. To do that, I
Part of an app I am working on includes a log file viewer, with
This part of an app that I am working on, I have the following

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.