//private delegate void SetPos(int ipos, string vinfo, int all); //private void update(int ipos, string vinfo, int all) //{ // if (this.InvokeRequired) // { // SetPos setpos = new SetPos(update); // this.Invoke(setpos, new object[] { ipos, vinfo, all }); // } // else // { // this.label1.Text = ipos.ToString() + "/" + all.ToString(); // this.progressBar1.Maximum = Convert.ToInt32(all); // this.progressBar1.Value = Convert.ToInt32(ipos); // this.textBox10.AppendText(vinfo); // } //} public void progressTest(object mg) { MayGod mgd = mg as MayGod; Form3 frm3 = new Form3(); this.BeginInvoke((MethodInvoker)(() => frm3.Show())); //使用BeginInvoke将控件赋值给主线程调用 frm3.showProgress(mgd); }
public void showProgress(MayGod mg) { progressBar1.Value = mg.number; }