Click here to Skip to main content
15,888,733 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hello Guys, i am making a splash screen in my project there is not issue in visual studio but when i run so i get an error Thread was being aborted and application closed after this error i am first time using thread so i such not an idea about this error well guys please help see my code and tell me what is wrong with it
Thanks.

What I have tried:

public Splash_Screen()
        {
            Thread t = (new Thread(Splash));
            t.Start();
            InitializeComponent();
            
            //loading data
            string str = string.Empty;
            for (int i = 0; i < 49000; i++)
            {
            	str += i.ToString();
            }
            //complete
            t.Abort();
        }
        void Splash()
        {
            SplashScreen.SplashForm frm = new SplashScreen.SplashForm();
            frm.AppName = "FinalPOS";
            frm.Icon = Properties.Resources.finalpos;
            frm.ShowIcon = true;
            Application.Run(frm);
            frm.ShowInTaskbar = false;
            //frm.BackColor = Color.Transparent;
            
        }
Posted
Updated 9-Jul-17 8:04am

Try this code. It's working fine for me.

C#
void splash()
{
    try {
        SplashScreen.SplashForm frm = new SplashScreen.SplashForm();
        frm.AppName = "HR";

        Application.Run(frm);
    }
    catch (ThreadAbortException ex)
    {
        Thread.ResetAbort();
    }
}
 
Share this answer
 
v2
Comments
Member 9983063 9-Jul-17 20:40pm    
Hey Thank you so much, bro, it's working fine for me too Thank you so much once again
.
hadi ur rehman 10-Jul-17 4:12am    
Your welcome
Your code calls Thread.Abort Method (Object) (System.Threading)[^] and does nothing else.
 
Share this answer
 
Comments
Member 9983063 9-Jul-17 8:04am    
Sir can you please give me the solution of this problem to my code bcz when i remove t.abort so it's running after new form open how to close it or hide it
Richard MacCutchan 9-Jul-17 10:18am    
Just Google for "C# splash screen" and look at the examples you find.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900