几秒钟后自动在C#中隐藏一个窗体并显示另一个窗体

几秒钟后自动在C#中隐藏一个窗体并显示另一个窗体,c#,winforms,c#-4.0,C#,Winforms,C# 4.0,我需要在几秒钟后隐藏当前窗体,然后显示任何窗体 我正在写这段代码,但它不起作用 namespace tempprj { public partial class ProfileFrm : Telerik.WinControls.UI.RadForm { public ProfileFrm() { InitializeComponent(); } private void ProfileFrm_Load

我需要在几秒钟后隐藏当前窗体,然后显示任何窗体

我正在写这段代码,但它不起作用

namespace tempprj
{
    public partial class ProfileFrm : Telerik.WinControls.UI.RadForm
    {
       public ProfileFrm()
       {
           InitializeComponent();
       }

       private void ProfileFrm_Load(object sender, EventArgs e)
       {
            Frm2 child = new Frm2();
            Thread.Sleep(3000);
            this.Hide();
            child.ShowDialog();
       }
   }
}

将阻止您的项目在3秒内执行任何操作(不包括其他线程),并冻结UI。我建议使用标准的.NET计时器


这是我问题的解决方案:

    private void ProfileFrm_Load(object sender, EventArgs e)
    {
        timer1.Tick += new EventHandler(timer1_Tick);

        timer1.Enabled = true;
        timer1.Interval = 4000;
        timer1.Start();

    }

    private void timer1_Tick(object sender, EventArgs e)
    {
        timer1.Stop();

        this.Hide();
        Frm2 f = new Frm2();

        f.ShowDialog();
    }

你想做一个闪屏吗?
    private void ProfileFrm_Load(object sender, EventArgs e)
    {
        timer1.Tick += new EventHandler(timer1_Tick);

        timer1.Enabled = true;
        timer1.Interval = 4000;
        timer1.Start();

    }

    private void timer1_Tick(object sender, EventArgs e)
    {
        timer1.Stop();

        this.Hide();
        Frm2 f = new Frm2();

        f.ShowDialog();
    }