C#多线程使用进度条

C#多线程使用进度条

 //声明一个委托
        public delegate void UpdateBar(int iBar);
        //委托使用进度条
        void UpdateMyBar(int iMyBar)
        {
            if (this.progressBar1.Value != this.progressBar1.Maximum)
            {
                if (this.progressBar1.InvokeRequired)
                {
                    UpdateBar pb = new UpdateBar(UpdateMyBar);
                    IAsyncResult pbaResult = this.progressBar1.BeginInvoke(pb, new object[] { iMyBar});
                    try { pb.EndInvoke(pbaResult); }
                    catch { }
                }
                else { this.progressBar1.Value++; }
            }
        }
posted @ 2010-01-12 18:12  tianmomi  阅读(467)  评论(0编辑  收藏  举报