passing parameters to a thread

Posted by assassin on Stack Overflow See other posts from Stack Overflow or by assassin
Published on 2010-05-11T16:52:50Z Indexed on 2010/05/11 17:04 UTC
Read the original article Hit count: 169

Filed under:
|
|

I want to pass a function that takes a parameter to the ThreadStart Constructor in C#. But, it seems that this is not possible, as I get a syntax error it I try to do something like this

Thread t1 = new Thread(new Thread Start(func1(obj1));

where obj1 is an object of type List<string> (say).

If I want a thread to execute this function that takes in an object as a parameter, and I plan to create 2 such threads simultaneously with different parameter values what is the best method to achieve this?

© Stack Overflow or respective owner

Related posts about c#

Related posts about thread