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 6844257
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T00:21:15+00:00 2026-05-27T00:21:15+00:00

I have run into a problem with a custom wpf splash-screen implementation. The problem

  • 0

I have run into a problem with a custom wpf splash-screen implementation.
The problem is that after the loading is finished and the MainWindow should be shown, it sometimes is not brought to front i.e Activate() call fails. It happens maybe 1/10 times. Application is run on Windows7/64.

Here is the implmentation (full source sample)

public partial class App : Application
{
    private Splash _splash;
    private SplashVM _viewModel;

    protected override void OnStartup(StartupEventArgs e)
    {
        base.OnStartup(e);

        // starts splash in separate GUI thread
        StartSplash();

        // continues on loading main application in main gui thread
        LoadMainAppFakeSteps(1000, 3);

        // tells splash screen to start shutting down
        Stop();

        // Creates mainwindow for application
        // The problem is that the mainwindow sometimes fails to activate, 
        // even when user has not touched mouse or keyboard (i.e has not given any other programs or components focus)
        MainWindow = new Shell();
        MainWindow.Show();
        MainWindow.Activate();
    }

    private void StartSplash()
    {
        _viewModel = new SplashVM();
        var thread = new Thread(SplashThread);
        thread.SetApartmentState(ApartmentState.STA);
        thread.IsBackground = true;
        thread.Start(_viewModel);
    }

    private void SplashThread(object vm)
    {
        _splash = new Splash();
        _splash.DataContext = vm;
        _splash.Show();

        System.Windows.Threading.Dispatcher.Run();

        _splash = null;
        _viewModel = null;
    }

    private void LoadMainAppFakeSteps(int stepDelayMs, int numSteps)
    {
        for (int i = 1; i <= numSteps; i++)
        {
            _viewModel.Text = i.ToString();
            Thread.Sleep(stepDelayMs);
        }
    }

    private void Stop()
    {
        if (_splash == null) throw new InvalidOperationException("Not showing splash screen");

        _splash.Dispatcher.BeginInvokeShutdown(DispatcherPriority.Normal);
    }
}

I tried this:

MainWindow = new Shell();
MainWindow.Topmost = true;
MainWindow.Show();
MainWindow.Activate();
MainWindow.Topmost = false;

and it seems to work, thanks all your suggestions

  • 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-27T00:21:16+00:00Added an answer on May 27, 2026 at 12:21 am
    MainWindow = new Shell();
    MainWindow.Topmost = true;
    MainWindow.Show();
    MainWindow.Activate();
    MainWindow.Topmost = false;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have run into a problem w/ my model for databinding in WPF. I
I've just installed VS2008 and have run into a problem that I'm sure can
I'm implementing some custom serialization (to byte array), and have run into a problem
I have run into a very interesting problem trying to debug my custom PHP
here's a problem that i've run into lately: I have a listview with a
I have run into this problem: Custom Methods & Extension Methods cannot be translated
I have run into this problem before but never quite solved it. I have
I have run into a problem trying to modify a form I myself have
I have run into a problem... I'm trying to use QTKit in an application
it seems I have run into a problem with Internet Explorer 7. I have

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.