0

I used metro framework for create splash screen, but when i use .Abort() function for thread then the splash screen is not working at all. But if i use .Suspend() it's working but even after the main form load, splash screen is not disposing. Here is the code,

    public Login()
    {
        Thread t = new Thread(new ThreadStart(loading));
        t.Start();
        InitializeComponent();

        for(int i = 0; i <= 1000; i++)
        {
            Thread.Sleep(10);
            t.Abort(); 
        }
    }

     void loading()
    {
        Splash frmsplash = new Splash();Application.Run(frmsplash);

    }

here is splash screen code,

public partial class Splash : MetroFramework.Forms.MetroForm
{
    public Splash()
    {
        InitializeComponent();
    }
}
Lakshan
  • 297
  • 1
  • 3
  • 14

2 Answers2

1

Thread.Abort is raised again and again until it's handled with Thread.ResetAbort... consider using join or interrupt and waiting for the thread to exit.

Jay
  • 3,276
  • 1
  • 28
  • 38
  • i already tried that way but it didn't work, after login screen appeared, splash screen remains. – Lakshan Sep 02 '18 at 03:41
0

I found a solution but do not know whether it'll work for every one, I just put t.Abort() outside the for loop, it does work for me.

Lakshan
  • 297
  • 1
  • 3
  • 14