I’m trying to pass parameters through the following:
Thread thread = new Thread(new ParameterizedThreadStart(DoMethod));
Any idea how to do this? I’d appreciate some help
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
lazyberezovsky has the right answer. I want to note that technically you can pass an arbitrary number of arguments using lambda expression due to variable capture:
This is a handy way of calling methods that don’t fit the
ThreadStartorParameterizedThreadStartdelegate, but be careful that you can easily cause a data race if you change the arguments in the parent thread after passing them to the child thread’s code.