简体   繁体   中英

Splash screen(MetroFramework) is not displaying C#?

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();
    }
}

Thread.Abort一次又一次地引发,直到用Thread.ResetAbort处理为止。...考虑使用join或interrupt并等待线程退出。

我找到了一个解决方案,但不知道它是否对每个人都适用,我只是将t.Abort()放在for循环之外,它确实对我t.Abort()

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM