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

  • Home
  • SEARCH
  • 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 6142007
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T18:19:42+00:00 2026-05-23T18:19:42+00:00

My Solution: So I managed to find another tutorial http://www.codeproject.com/KB/dotnet/Yet_Another_Splash_Screen.aspx and the sourcecode seemed

  • 0

My Solution:

So I managed to find another tutorial http://www.codeproject.com/KB/dotnet/Yet_Another_Splash_Screen.aspx and the sourcecode seemed to make more sense to me. Here is the code i’m using now. Main() is left untouched.

Splash.cs

`

public partial class Frm_Splash : Form
{
delegate void ProgressDelegate(int percent);
delegate void SplashShowCloseDelegate();

    /// <summary>
    /// To ensure splash screen is closed using the API and not by keyboard or any other things
    /// </summary>
    bool CloseSplashScreenFlag = false;

    /// <summary>
    /// Base constructor
    /// </summary>
    /// 
    public Frm_Splash()
    {
        InitializeComponent();
        progress_Splash.Show();
        this.ClientSize = this.BackgroundImage.Size;
    }

    public void ShowSplashScreen()
    {
        if (InvokeRequired)
        {
            // We're not in the UI thread, so we need to call BeginInvoke
            BeginInvoke(new SplashShowCloseDelegate(ShowSplashScreen));
            return;
        }
        this.Show();
        Application.Run(this);
    }

    /// <summary>
    /// Closes the SplashScreen
    /// </summary>
    public void CloseSplashScreen()
    {
        if (InvokeRequired)
        {
            // We're not in the UI thread, so we need to call BeginInvoke
            BeginInvoke(new SplashShowCloseDelegate(CloseSplashScreen));
            return;
        }
        CloseSplashScreenFlag = true;
        this.Close();
    }

    /// <summary>
    /// Update text in default green color of success message
    /// </summary>
    /// <param name="Text">Message</param>
    public void Progress(int percent)
    {
        if (InvokeRequired)
        {
            // We're not in the UI thread, so we need to call BeginInvoke
            BeginInvoke(new ProgressDelegate(Progress), new object[] { percent });
            return;
        }
        // Must be on the UI thread if we've got this far
        progress_Splash.Value = percent;
        // Fade in the splash screen - looks pro. :D
       if (percent < 10)
            this.Opacity = this.Opacity + .15;
    }


    /// <summary>
    /// Prevents the closing of form other than by calling the CloseSplashScreen function
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    private void SplashForm_FormClosing(object sender, FormClosingEventArgs e)
    {
        if (CloseSplashScreenFlag == false)
            e.Cancel = true;
    }
 }`

Form1.cs

public partial class Frm_Main : Form
{
    Frm_Splash frm_Splash = new Frm_Splash();

    public Frm_Main()
    {
        this.Hide();
        Thread splashthread = new Thread(new ThreadStart(frm_Splash.ShowSplashScreen));
        splashthread.IsBackground = true;
        splashthread.Start();
        InitializeComponent();
        CenterToScreen();
    }

    private void Frm_Main_Load(object sender, EventArgs e)
    {
        if (PassedAll() == true)
            FillMovieLB();
        if (FillMovieProgress == 100)
        {
            //Throw in this sleep so the user can see the progress bar reach all the way to the end.
            Thread.Sleep(1000);
            this.Show();
            frm_Splash.CloseSplashScreen();
            this.Activate();
        }
    }

Original Question

G’day all,

I’m very new to programming in C# and i’m having a problem with the http://www.codeproject.com/KB/cs/prettygoodsplashscreen.aspx tutorial and implementing it within my application. I’m finding it a little difficult to understand what the problem is. I know there is alot of stuff about getting this splash screen to work but I can’t get my head around it.

When I start the program, the Frm_Main will display, you can see the listbox being populated, because i’ve placed it in BackgroundWorker.DoWork(), and then afterwards my frm_Splash will show after the work is done. Obviously, the way it should be working is, frm_Splash will show during the work being done on Frm_Main, and the progress bar will show the progress of the loading (this part I haven’t implemented yet).

Edit: I may not have been clear, but the question is: How can I get my splashscreen to display while the work is being done and before the main form is displayed?

Thanks everybody. 🙂

Here is my code:

   static Frm_Splash frm_Splash = new Frm_Splash();

    public delegate void ShowFormDelegate();

    public void ShowForm()
    {
        frm_Splash.Show();
    }

    public Frm_Main()
    {
        InitializeComponent();
        CenterToScreen();
        if (PassedAll() == true)
        {
            back_loadprog.RunWorkerAsync();  
        }
    }

   private void back_loadprog_DoWork(object sender, DoWorkEventArgs e)
    {
        Invoke(new ShowFormDelegate(ShowForm));
        Invoke(new FillMovieLBDelegate(FillMovieLB));
    }
  • 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-23T18:19:43+00:00Added an answer on May 23, 2026 at 6:19 pm

    Here, have some code… Works for me.

    Splash Form:

    namespace Screens.Forms
    {
        public partial class Splash : DevExpress.XtraEditors.XtraForm
        {
            public Splash()
            {
                InitializeComponent();
            }
            string RandomLoadingMessage()
            {
                string[] lines ={
                    "Pripremam warp pogon",
                    "Moj drugi ekran za učitavanje je brži, probaj njega",
                    "Verzija programa koju imam u testiranju imala je smiješnije poruke"
                };
                return lines[new Random().Next(lines.Length)];
            }
            public void RandomizeText()
            {
                lblMessage.Text = RandomLoadingMessage();
            }
            private void Splash_Load(object sender, EventArgs e)
            {
                RandomizeText();
            }
            private static Splash _splash;
            private static bool _shouldClose;
    
            static void ThreadFunc()
            {
                _splash = new Splash();
                _splash.Show();
                while (!_shouldClose)
                {
                    Application.DoEvents();
                    Thread.Sleep(100);
                    if (new Random().Next(1000) < 10)
                    {
                        _splash.Invoke(new MethodInvoker(_splash.RandomizeText));
                    }
                }
                for (int n = 0; n < 18; n++)
                {
                    Application.DoEvents();
                    Thread.Sleep(60);
                }
                if (_splash != null)
                {
                    _splash.Close();
                    _splash = null;
                }
            }
            static public void ShowSplash()
            {
                _shouldClose = false;
                Thread t = new Thread(ThreadFunc);
                t.Priority = ThreadPriority.Lowest;
                t.Start();
            }
            internal static void RemoveSplash()
            {
                _shouldClose = true;
            }
            internal static void ShowSplash(List<string> fromTwitterMessages)
            {
                ShowSplash();
            }
        }
    }
    

    Show it with:

    Splash.ShowSplash();
    

    Do the work you need, then when done:

    Splash.RemoveSplash();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need help because I didn't find out a solution for a project where
I have been trying to find a solution for this for a while but
I have a DBPro (DataDude) project inside my solution to manage and version the
How do you manage revisions of stored procedures? We have a BI solution on
I've got a couple DNN portals I manage and I need a solution to
I am creating a new database to manage wish lists. Solution A: Two tables,
I was hired by my current employer to develop an e-commerce solution. My manager
Solution -- WorkflowProject   -- Workflow1   -- Workflow2 -- WebProject (WAP)   -- App_Data     -- MyDatabase.vdb3
Solution: I've misinterpreted the example from SQL Books Online. Yes, that below the section
Solution to original problem (below) may have been discovered. I commented out <identity> ...

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.