Splash screen(MetroFramework) is not displaying C#?

大憨熊 提交于 2019-12-11 18:56:18

问题


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

回答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.




回答2:


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.



来源:https://stackoverflow.com/questions/52127205/splash-screenmetroframework-is-not-displaying-c

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!