.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代码?
您需要为州创建一个类:
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();