splash简单示例

第一个类

public class HCSplash
{
  private Form2 m_Form = new Form2();

  public void Start()
  {
    DateTime dtStart = DateTime.Now;

  Thread t = new System.Threading.Thread(new ThreadStart(delegate
  {
    m_Form.ShowDialog();
  }));
  t.Start();

  Thread.Sleep(5000);
  }

  public void Stop()
  {
    m_Form.KillMe();
  }
}

 

 

第二个类

public partial class Form2 : Form
{
  public Form2()
  {
    InitializeComponent();
  }

  private void Form2_Load(object sender, EventArgs e)
  {
    this.timer1.Start();
  }

  public void KillMe()
  {
    this.BeginInvoke(new MethodInvoker(delegate
    {
      this.Close();
    }));
  }

  private void timer1_Tick(object sender, EventArgs e)
  {
    this.progressBar1.Value += 10;

    if (this.progressBar1.Value >= this.progressBar1.Maximum)
    {
      this.progressBar1.Value = this.progressBar1.Minimum;
    }
  }

}

 

posted on 2016-07-14 21:41  LongHuaiYu  阅读(225)  评论(0编辑  收藏  举报