是否可以移动控件或至少将控件复制到另一个线程,然后创建它。原因是我想控制加载完全在后台线程,然后一旦完成加载我想将控制移动到另一个线程。例如:winforms - 将控件移动到另一个线程
BackgrundworkRunasync(object sender, DoWorkEventArgs e)
{
var GetData = GetData();
CreateControl mycontrol = new CreateControl() //Tyep of WindowsForm
mycontrol.Data = GetData;
e.Result = mycontrol;
}
BackGroundWorkerComplete (object sender, RunWorkerCompletedEventArgs e)
{
CreateControl con = (CreateControl)e.Result;
con.mdiparent = this;
con.Show();
//Of course this is a cross threading exception. Can I move this control to the current thread or even create a control in the current thread and do a deep copy? Optimally I just want to move the control to another thread, can you do this?
}