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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T07:09:41+00:00 2026-05-16T07:09:41+00:00

The concept of a splash screen doesn’t strike me as something that should be

  • 0

The concept of a splash screen doesn’t strike me as something that should be so complicated, but I’m having trouble getting the whole splash screen painted.

Let’s say I have two System.Windows.Forms.Forms: RealForm and SplashScreen. The RealForm contains the initial GUI. During the RealForm’s loading process (that is, in the event handler for the Load event), RealForm creates a connection to a database and then tests the connection. This can take several seconds, so before I do all of this, I try to throw up a splash screen like so:

private void RealForm_Load(object sender, EventArgs e)
{
    SplashScreen splash = new SplashScreen();
    splash.Show();
    loadAndCheckDatabase();
    splash.Close();
}

The problem is that the splash screen only gets partially drawn and so it doesn’t really look like much of a splash screen. Any idea why? What should I do?

For bonus points, does anyone know where to find an explanation for all series of events that occur in typical creation, usage, and destruction of forms? The above problem is probably because I don’t understand what order things occur or where to hook into form events.


UPDATE
Close, but not quite: looking for a little more advice. Here’s the current code:

private SplashScreen splash = new SplashScreen();

private void RealForm_Load(object sender, EventArgs e)
{

    splash.Show();

    BackgroundWorker worker = new BackgroundWorker();
    worker.DoWork += new DoWorkEventHandler(worker_DoWork);
    worker.RunWorkerCompleted += new RunWorkerCompletedEventHandler
         (worker_RunWorkerCompleted);
    worker.RunWorkerAsync();
    this.Visible = false;

}

void worker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
{
    splash.Close();
    this.Visible = true;
}

void worker_DoWork(object sender, DoWorkEventArgs e)
{
    loadAndCheckDatabase();
}

Unfortunately, the this.Visible = false doesn’t do anything, because it is automatically set to true in code that I don’t control. So, to get around this, I put the this.Visible = false into the handler for the form’s Shown event. However, as you can probably guess, you can still see the form for a split second… so this is not really a good solution.

Is there any way to wait on the worker thread while I’m still in the Load handler?

  • 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-16T07:09:41+00:00Added an answer on May 16, 2026 at 7:09 am

    You are displaying the splash screen and checking your database on the same thread. The thread can only do one thing at a time.

    A quick and cheap way to fix this is to have loadAndCheckDatabase() call Application.DoEvents() periodically. However that’s a cheap fix.

    You really want to run loadAndCheckDatabase() on its own thread, a BackgroundWorker is a nice simple way to do this.

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

Sidebar

Related Questions

The concept of this seems easy, but I'm having trouble getting it right and
I think that the concept is right here but it doesn't seem to work
Simple concept, but I'm having trouble coming up with an elegant solution. I've got
I completely understand the concept of expression trees, but I am having a hard
The concept of a coroutine sounds very interesting, but I don't know, if it
This concept seems to trouble me. Why does an NSError object need its pointer
The concept of adding a variable to a class's extension is something I am
Is there a concept of pointers or anything similar to that in as3? I
I know the concept of singleton in Java. I'm having problems with creating singleton
I remember encountering this concept before, but can't find it in Google now. If

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.