/// <summary> /// Initializes a new instance of the <see cref="ProgressWindowTest"/> class. /// </summary> public ProgressWindowTest() { this.Hide(); SplashWindowForm splashWindowForm = new SplashWindowForm(); splashWindowForm.Text = "测试工作"; System.Threading.ThreadPool.QueueUserWorkItem(new System.Threading.WaitCallback(SplashDoWork), splashWindowForm); splashWindowForm.ShowDialog(); InitializeComponent(); }
/// <summary> /// Does some work. /// </summary> /// <param name="status">The status.</param> private void SplashDoWork(object status) { SplashWindowForm splashWindowForm = status as SplashWindowForm; try { splashWindowForm.BeginThread(0, 300); for (int i = 0; i < 100; ++i) { splashWindowForm.SetDisplayText("加载启动项1...."); splashWindowForm.StepTo(i); if (splashWindowForm.IsAborting) { return; } System.Threading.Thread.Sleep(100); if (splashWindowForm.IsAborting) { return; } } for (int i = 100; i < 200; ++i) { splashWindowForm.SetDisplayText("加载启动项2...."); splashWindowForm.StepTo(i); if (splashWindowForm.IsAborting) { return; } System.Threading.Thread.Sleep(100); if (splashWindowForm.IsAborting) { return; } } for (int i = 200; i < 300; ++i) { splashWindowForm.SetDisplayText("加载启动项3...."); splashWindowForm.StepTo(i); if (splashWindowForm.IsAborting) { return; } System.Threading.Thread.Sleep(100); if (splashWindowForm.IsAborting) { return; } } } catch (Exception exception) { MessageBox.Show(exception.Message + Environment.NewLine + exception.StackTrace); } finally { if (splashWindowForm != null) { splashWindowForm.End(); } } }