如何在单独的线程上运行计时器

时间:2014-01-20 19:12:20

标签: c#

我需要使用进度条制作闪屏。我的问题是我无法将主窗体与启动画面链接:

public LogIn_Form() {
    Thread t = new Thread(new ThreadStart(SplashStart));
    t.Start();
    Thread.Sleep(5000);
    InitializeComponent();
    t.Abort();
}

public void SplashStart() {
    Application.Run(new Form1());
}

我有“Application.Run(new Form1());”它在Form1下给我一个错误。

这是启动画面形式:

public SplashScreen_Form() {
    InitializeComponent();
    timer.Start();
}

private void timer_Tick(object sender, EventArgs e) {
    this.Opacity += 0.07;

    pbrLoad.Increment(1);
    if (pbrLoad.Value == 100) 
        timer.Stop();
}

private void SplashScreen_Form_Load(object sender, EventArgs e) {
    this.Opacity = 0;
    timer.Enabled = true;
}

现在我需要保持这样,但没有错误。

0 个答案:

没有答案
相关问题