请问大家线程怎么传参数啊
Thread t = new Thread(new ThreadStart(Build))
public void Build(string a,string b)
{
.......
}
我这个方法是带参数的,怎么弄 啊
------解决方案--------------------1.1需要用个辅助的类来传递参数
------解决方案--------------------把分给我吧!
使用全局变量取代参数:
Thread t = new Thread(new ThreadStart(Build))
public string a =值;
public string b = 值:
public void Build()
{
直接使用a,b就行了,这样就不用参数了.......哈哈
}
______________________________________________
Mr xing
email&msn:xingtaisen@126.com
QQ:654 1798 16
______________________________________________
------解决方案--------------------或者这样,用个类包装一下:
MyThreadClass myThreadClass = new MyThreadClass();
myThreadClass.a = string.Empty;
myThreadClass.b = string.Empty;
Thread t = new Thread (new ThreadStart (myThreadClass.DoBuildJob );
t.Start ();
private class MyThreadClass
{
public string a;
public string b;
public void DoBuildJob()
{
//Do something wiht a, b.
}
}
------解决方案--------------------调用class中的方法
class构造的时候可以有参数