日期:2014-05-17  浏览次数:20774 次

为什么使用了BackgroundWorker,窗体还是处于假死状态,赐教
 private void MyBackWorker_ProgressChanged(object sender, ProgressChangedEventArgs e)
        {
            try
            {
                this.MyBar.Value = e.ProgressPercentage;
                this.labMessage.Text = e.UserState.ToString();
                this.labMessage.Update();
            }
            catch(Exception Ex)
            {
                MessageBox.Show(Ex.Message.ToString());
            }
        }

        private void MyBackWorker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
        {
            //线程处理完成时
            try
            {
                MessageBox.Show("完成!");
            }
            catch(Exception Ex)
            {
                MessageBox.Show(Ex.Message.ToString());
            }
        }

        private void MyBackWorker_DoWork(object sender, DoWorkEventArgs e)
        {
            //开始执行后台程序
            try
            {   
                this.work(MyBackWorker,e);
            }
            catch(Exception Ex)
            {
                MessageBox.Show(Ex.Message.ToString());
            }
        }

        private void work(BackgroundWorker bk,DoWorkEventArgs e)
        {
            int Nums = 1000000;
     &nb