views:

1154

answers:

1

.NET 1.1 lacks ParameterizedThreadStart (I have to use 1.1 because it's the last one supporting NT 4.0)

In .NET 2.0, I would simply write:

Thread clientThread = new Thread(new ParameterizedThreadStart(SomeThreadProc));
clientThread.Start(someThreadParams);

How can I create equivalent .NET 1.1 code?

+3  A: 

You would need to create a class for the state:

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();
Marc Gravell
I missed the `new ThreadStart(` part before, which does work - but only on 2.0 (1.1 missing anonymous delegates).
skolima