Question

.NET 1.1 manque de ParameterizedThreadStart (je dois utiliser 1.1 car c'est le dernier supportant NT 4.0)

Dans .NET 2.0, j'écrirais simplement:

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

Comment créer un code .NET 1.1 équivalent?

Était-ce utile?

La solution

Vous devez créer une classe pour l'état:

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();
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top