如何正确启动和终止表单线程

时间:2017-10-24 06:30:22

标签: c# multithreading

如何正确启动新表单(仅显示logo.jpg)作为新线程并在不同(无时间限制)时刻终止? 我有一个像下面这样的工作解决方案,但我猜中止并不是最好的选择 - 有时在关闭主程序后停留,直到鼠标移动。请告知如何让它变得更好......

//field declarations:
        frmLogo frmStart = new frmLogo();
        private Thread startLogoThread;

public main()
        {
            this.startLogoThread = new Thread(new ThreadStart(this.frmLogoStart));
            this.startLogoThread.Start();
            InitializeComponent();
        }

        private void frmLogoStart()
        {
            System.Windows.Forms.Application.Run(frmStart);
        }

 private void mainForm_Load(object sender, EventArgs e)
        {
            // loading of SQL  
            // this is a point where I want to kill the logo thread
            this.startLogoThread.Abort();
            this.BringToFront();
        }

0 个答案:

没有答案