谁知道该怎么解决这个问题?
编译提示:未处理的“System.ArgumentException”类型的异常出现在 system.windows.forms.dll 中。其他信息: 在某个线程上创建的控件不能成为在另一个线程上创建的控件的父级。

解决方案 »

  1.   

    你应当在创建UI的线程中操作UI。
    如果在其它线程中要操作UI的话,需要使用BeginInvoke的方法。
      

  2.   

    不要在创建控件以外的线程操作控件,一直以来都有这么一个约定,不知道为什么很难找到,.Net 2.0已经把这个作为异常了。可以使用Control的Invoke方法,将操作放到UI线程上。private void Form1_Load(object sender, System.EventArgs e)
    {
        System.Threading.Thread tNew = new System.Threading.Thread    (new     System.Threading.ThreadStart(this.Test));
        tNew.Start();
    }delegate void SetDataDelegate();private void SetData()
    {
       this.datagrid1.DataSource = ds;
    }private void Test()
    {
       this.Invoke(new SetDataDelegate(SetData));
    }
      

  3.   

    我想这个原因是不是因为,.net中控件就是按照独占模式设计的。
    它不是按照windows中系统设备那样设计出来的。比如一个声音Device可能发出两个播放器的声音
    新线程是并发的。
      

  4.   

    不要在创建控件以外的线程操作控件
    that's right请参考:http://community.csdn.net/Expert/TopicView.asp?id=4345733