RT。
1、请问我用怎么才能多线程传递参数呢?
2、我怎么才能多线程调用一个类里面的方法?我这样写:            Thread mythread = new Thread(new ThreadStart(mystatus.function)).Start();
提示错误为:错误 1 “function”的重载均与委托“System.Threading.ThreadStart”不匹配
mystatus类里面的function方法需要传进一个string的参数,没有返回值。

解决方案 »

  1.   

    在类里增加一个args和属性Args,function不要加参数,直接使用args
    class Mystatus
    {
      string args;
      public string Args{get{return args;}set{args=value}}
      public void function(){}
    }
    mystatus.Args="hahaha";
    Thread mythread = new Thread(new ThreadStart(mystatus.function)).Start(); 
      

  2.   

     public void function(object str){} //string类型换成object 类型,方法里面再去转化Thread mythread = new Thread(mystatus.function).Start(); 
      

  3.   


            private void button1_Click(object sender, EventArgs e)
            {
                new Thread(new ParameterizedThreadStart(dosomething)).Start("abc");
            }        private void dosomething(object input)
            {        }
      

  4.   

    public void function(object str){} //string类型换成object 类型,方法里面再去转化 
    Thread mythread = new Thread(mystatus.function).Start(参数); 漏了参数,实质就是楼上的代码