how to use ParameterizedThreadStart in c# I want to make threads take void method and this method take sqlconnection ?
how to use ParameterizedThreadStart in c# I want to make threads take void method
Share
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.
The
ParameterizedThreadStartdelegate only takes anObjectparameter, so the method has to match that. You have to cast theObjectreference toSqlConnectionin the method:When calling it you don’t have to specifically cast the
SqlConnectiontoObject, that is done implicitly:However, you might want to consider that the method should create it’s own connection. The connection object is not thread safe, so you can’t use the same connetion object in more than one thread at a time.