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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T16:00:41+00:00 2026-05-17T16:00:41+00:00

My desktop-based WPF-application (4.0) works with DB and in order to this it should

  • 0

My desktop-based WPF-application (4.0) works with DB and in order to this it should establish a connection with SQL Server on application’s startup. Of course, this operation takes some time and user have to wait some seconds (3-5) while .Net Framework start and connect to SQL Server.

As appropriate in such kind of cases I decided to use a splash screen. I added some picture to the solution, set build action as «Splash screen», compiled my application, it works! If the attempt to connect to SQL Server failed (e.g. server is not available) my application throws an exception and I show to user MessageBox with warning and exception details, user press OK and application shutdowns (Application.Current.Shutdown()).

Before I added splash screen all this logic used to work perfectly, but now, with splash screen added, if I run application while SQL Server is not available, application throws an exception (as I asked in my code), but MessageBox with notification appears for 1-2 seconds and disappear without any user interaction, user even can’t read what is written on it.

I discovered, that if I try to show 2 MessagBoxes, so the first one will appear and disappear immediately, but the second one will stay until the user will press OK.

How to solve this issue? I want to use splash screen and show one MessageBox if an exception has been thrown and let the user to decide when to close it (user click on the OK button).

Here is a flow chart describes logic of my application:

No exception (good scenario):
Run app → Splash screen → if(isConnectedToSQL=true) → Show main window…

With exception (bad scenario):
Run app → Splash screen → if(isConnectedToSQL=false) → Throw exception → Show MessageBox with exception details → User click on OK → Close application.

  • 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-17T16:00:42+00:00Added an answer on May 17, 2026 at 4:00 pm

    The reason lies in how the SplashScreen uses BeginInvoke to Close itself. I couldn’t pin down exactly where the MessageBox is getting closed*, but I did see a simple fix:

    Don’t use MessageBox.

    Create an error window, let’s call it “ErrorWindow.xaml”. Use that window to display the error message to the user and respond to the OK button.

    Follow this guideline to declare your own Main procedure and alter it like so:

    Edited to show how you might pass info to the ErrorWindow.

    public static void Main()
    {
        SplashScreen splashScreen = new SplashScreen("whatever.jpg");
        splashScreen.Show(true);
        string errorMessage;
        bool dataLoaded = LoadDataFromDatabase(out errorMessage);
        WpfApplication1.App app = new WpfApplication1.App();
        Window windowToRun = dataLoaded ? (Window)new MainWindow() : (Window)new ErrorWindow { ErrorMessage = errorMessage };
        app.Run(windowToRun);
    }
    
    • My guess is that SplashScreen.Show and Application.Run are two separate message pumps. The first is terminated with a call to PostQuitMessage. That explains why the MessageBox closes.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I develop desktop-based WPF-application, that uses SQL Server 2008 R2 Database and ADO.NET Entity
My WPF desktop-based application uses ADO.Net Entity Framework in order to connect to SQL
My GUI desktop-based WPF 4.0 (C# .Net 4.0) program works with SQL Server database.
In my WPF 4.0 desktop-based application in order to localize my application (e.g. English
I have WPF 4 desktop-based application. In one of the windows of this application,
I am testing one Desktop based client server application. I want to perform a
In my desktop-based WPF-application I want to implement a toolbar with key actions (add,
Given: WPF 4.0 desktop-based application. Basic input form with two TextBox fields and submit
In my WPF 4 desktop-based application, I have an LINQ query that makes a
In my WPF 4.0 desktop-based application, I want to add an ability to traverse

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.