在一个窗体里执行一段数据流的操作,操作时弹出一个窗体显示进度条,完毕后自动延时关闭
问题出现是在 延时的时候标签不显示
         private void CreatetAttach(string filePath)
        {
            Form frm = new Form();
            frm.Size = new System.Drawing.Size(300, _listView.SelectedItems.Count*36+60);
            frm.StartPosition = FormStartPosition.CenterScreen;
            frm.FormBorderStyle = FormBorderStyle.SizableToolWindow;
            frm.ShowInTaskbar = false;
            frm.Show();
            int y = 5;
            foreach (ListViewItem item in _listView.SelectedItems)
            {
                Label lable1 = new Label();
                lable1.Size = new System.Drawing.Size(280, 18);
                lable1.Text = item.Text;
                lable1.Location = new System.Drawing.Point(5, y);
                lable1.TextAlign = ContentAlignment.BottomLeft;
                lable1.BringToFront();
                frm.Controls.Add(lable1);
              
                ProgressBar progressBar1 = new ProgressBar();
                progressBar1.Anchor = ((System.Windows.Forms.AnchorStyles)  ((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)));
                progressBar1.Location = new System.Drawing.Point(5,y+18);
                progressBar1.MarqueeAnimationSpeed = 10;
                progressBar1.Size = new System.Drawing.Size(280, 13);
                progressBar1.Minimum = 0;
                progressBar1.BringToFront();
                frm.Controls.Add(progressBar1);
                y=y+36;
                
                XmlElement el = (XmlElement)_Docment.DocumentElement.SelectSingleNode("R[@fName='" + item.Text + "']");
                string fileName = filePath+@"/" + item.Text;
                
                if (File.Exists(fileName))  
                {
                    File.Delete(fileName);
                }
                using (FileStream fileStream = new FileStream(fileName, FileMode.Create, FileAccess.Write))
                {
                    byte[] info = Convert.FromBase64String(el.GetAttribute("fAttach"));
                    progressBar1.Maximum = info.Length;
                    progressBar1.Step = 10;
                    fileStream.Write(info, 0, info.Length);
                    
                    while (progressBar1.Value != info.Length)
                    {
                        progressBar1.PerformStep();
                    }
                    fileStream.Close();
                }
            }            Label lab = new Label();
            lab.Size = new System.Drawing.Size(280, 23);
            lab.Text = "下载文件完毕";
            lab.Location = new System.Drawing.Point(5, y+8);
            frm.Controls.Add(lab);
            frm.TopMost = true;
            System.Threading.Thread.Sleep(1000);
            frm.Close();            //frm.Deactivate += new EventHandler(frm_Deactivate);
        }