码迷,mamicode.com
首页 > Windows程序 > 详细

C# 自定义等待窗口

时间:2015-11-20 09:18:20      阅读:225      评论:0      收藏:0      [点我收藏+]

标签:

        private SynchronizationContext syncContext = null;

        public WaitWindow()
        {
            InitializeComponent();
            syncContext = SynchronizationContext.Current;
        }

        private void DisplayProgress()
        {
            while (true)
            {
                syncContext.Post(delegate (object target)
                {
                    Label lProgress = (Label)target;

                    if (lProgress.Left + lProgress.Width >= Width)
                    {
                        lProgress.Left = 0;
                    }
                    else
                    {
                        lProgress.Left += 10;
                    }
                }, lblProgress);
                Thread.Sleep(100);
            }
        }

        //waitWnd = new WaitWindow();
        //waitWnd.Owner = this;
        //waitWnd.Show();

        //if (waitWnd != null)
        //{
        //    waitWnd.Close();
        //}
        private void WaitWindow_Load(object sender, EventArgs e)
        {
            Thread runProgressThread = new Thread(new ThreadStart(DisplayProgress));
            runProgressThread.IsBackground = true;
            runProgressThread.Start();
        }

 

C# 自定义等待窗口

标签:

原文地址:http://www.cnblogs.com/ilookbo/p/4979709.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!