Can i make any function like
public void myfunc()
{
//some processing
}
a thread function by
Thread t = new Thread (new ThreadStart (myfunc));
then some where
t.Start();
and can i pass any type of arguments to that?
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.
In theory you can make any method execute in a separate thread, as long as you follow some rules (e.g. synchronization, invoke delegates to update ui, etc.).
From your question I understand that you do not have much experience with multi threaded programming, so I advise you to read a lot about threading and learn about the dangers and problems that can arise. You may also use the background worker class that take some of the responsibilities from you.
Also, yes, you can pass parameters to a thread method: