How can I create and start a parameterized thread in .NET 1.1?

3k Views Asked by At

.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?

1

There are 1 best solutions below

1
On BEST ANSWER

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();