您的位置:首页 > 编程语言 > C#

多线程实现大量数据加载时的等待画面

2013-06-10 13:08 295 查看
    public class Holder : IDisposable
    {
        public virtual void Dispose()
        {
        }
    }
   -----------------------------------
 

 

 public class SplashHolder : Holder
    {
        private readonly Thread _thread;

        public SplashHolder()
        {
            _thread = new Thread(_ShowWaitingForm);
            _thread.Start();
        }

        public override void Dispose()
        {
            SplashForm.RequestCancel();
            _thread.Join();
        }

        private void _ShowWaitingForm()
        {
            var f = new SplashForm {StartPosition = FormStartPosition.CenterScreen};
            f.ShowDialog();
        }
    }

 

调用

       using (new SplashHolder())
       {
          frm.show
Dispose(); //关闭等待画面
       }
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  C# 线程