在某个线程上创建的控件不能成为在另一个线程上创建的控件的父级

it2022-05-09  26

private   void   menuItemFoo_Click(object   sender,   System.EventArgs   e)     {     System.Threading.Thread   thread=new   System.Threading.Thread(new   System.Threading.ThreadStart(this.Foo));     thread.Start();     }         public   delegate   void   MyDelegate(Form   form);     System.Windows.Forms.Form   childForm;         private   void   AddMdiChild(Form   form)     {     form.MdiParent=this;     form.Show();     }         private   void   Foo()     {     childForm=new   Form();     //childForm.MdiParent=this;   //直接调用会出错     //childForm.Show();     this.Invoke(new   MyDelegate(this.AddMdiChild),new   object[]{childForm});     }            

转载于:https://www.cnblogs.com/nanshouyong326/archive/2009/07/13/1522335.html


最新回复(0)