.NET 1.1缺少ParameterizedThreadStart
(我必须使用1.1,因为它是支持NT 4.0的最后一个)
在.NET 2.0中,我只想写:
Thread clientThread = new Thread(new ParameterizedThreadStart(SomeThreadProc));
clientThread.Start(someThreadParams);
如何创建等效的.NET 1.1代码?
答案 0 :(得分:5)
您需要为州创建一个类:
class Foo {
private int bar;
public Foo(int bar) { // and any other args
this.bar = bar;
}
public void DoStuff() {
// ...something involving "bar"
}
}
...
Foo foo = new Foo(12);
Thread thread = new Thread(new ThreadStart(foo.DoStuff));
thread.Start();