日期:2014-05-18 浏览次数:22151 次
    public delegate void DeleTtt();
    public delegate void DeleTttt();
    public partial class Form2 : Form
    {
        public Form2()
        {
            InitializeComponent();
        }
        private void button1_Click(object sender, EventArgs e)
        {
            Thread t1 = new Thread(new ThreadStart(progressBarSample));
            t1.IsBackground = true;
            t1.Start();
            Thread t2 = new Thread(new ThreadStart(lblText));
            t2.IsBackground = true;
            t2.Start();
        }
        private void progressBarSample()
        {
            if (this.InvokeRequired)
            {
                this.Invoke(new DeleTttt(lblText));
            }
            else
            {
                for (int i = 0; i < this.progressBarSample2.Properties.Maximum; i += 50)
                {
                    this.progressBarSample2.Position += i;
                    Thread.Sleep(1500);
                }
            }
        }
        private void lblText()
        {
            if (this.InvokeRequired)
            {
                this.Invoke(new DeleTtt(lblText));
            }
            else
            {
                while (true)
                {
                    label2.Text += ".";
                    if (label2.Text.Length >= 4)
                    {
                        label2.Text = String.Empty;
                    }
                    Thread.Sleep(1000);
                }
            }
        }
    }