RT。
1、请问我用怎么才能多线程传递参数呢?
2、我怎么才能多线程调用一个类里面的方法?我这样写: Thread mythread = new Thread(new ThreadStart(mystatus.function)).Start();
提示错误为:错误 1 “function”的重载均与委托“System.Threading.ThreadStart”不匹配
mystatus类里面的function方法需要传进一个string的参数,没有返回值。
1、请问我用怎么才能多线程传递参数呢?
2、我怎么才能多线程调用一个类里面的方法?我这样写: Thread mythread = new Thread(new ThreadStart(mystatus.function)).Start();
提示错误为:错误 1 “function”的重载均与委托“System.Threading.ThreadStart”不匹配
mystatus类里面的function方法需要传进一个string的参数,没有返回值。
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();
private void button1_Click(object sender, EventArgs e)
{
new Thread(new ParameterizedThreadStart(dosomething)).Start("abc");
} private void dosomething(object input)
{ }
Thread mythread = new Thread(mystatus.function).Start(参数); 漏了参数,实质就是楼上的代码