How can I create and start a parameterized thread in .NET 1.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?

Answers


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

Need Your Help

How to convert string to uppercase in windows textbox?

c# winforms textbox uppercase

I've a textbox in my windows application. It allows only alphabets and digits. I want when ever I type any alphabet, it should be converted to uppercase.How can I do that and in which event? I've u...

How do you hash a string? I need random strings somehow turned into integers to put them in my hash table

c++ hashtable type-conversion hash

For example, "foobar" should hash to something like 3456. My hash table array has size 811, so my hash function will do 3456 % 811 to find the position in the hash table to place "foobar".

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.