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 splash screen. I added some picture to solution, set build action as «Splash screen», compiled my application, it works! If attempt to connect with 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 perfect, 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 with out 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 user will press OK.
My question is: How to solve this issue? I want to use splash screen and show one MessageBox if exception has been thrown and let user to decide when to close it (user click on 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.
Thanks.