Thursday, August 6, 2009

Another way to pass data into a thread

In the previous thread post I showed a way you can pass information into a thread. Here is another way in which you instantiate the class containing the method you want your thread to call first.
Math math = new Math();
math.Value1 = 1;
math.Value2 = 3;

ThreadPool.QueueUserWorkItem(math.Add);
Now when math.Add is called, it has all the information it needs to do its work.