Hi,
In addition to what you can find in Jon's site I want to give you one more
idea.
You can decalre a delegate for the method you want to start in a thread.
//Delegate and the method itslef might have a return value as well
delegate void ThreadMethod(string aParameter, int anotherParameter) ;
public void DoSomething(string aParameter, int anotherParameter) {
....
}
ThreadMethod starter = new ThreadMethod(DoSomething);
Now you can start DoSomething in a separate thread:
starter.BeginInvoke(param1, param2, null, null);
You can use IAsyncResult returned by BeginInvoke and use EndInvoke to wait
for the thread to finish and get result. You can optain a wait handle,
checking periodically IAsyncResult.IsCompleted or using callback method. You
have options.
Begin invoke uses a thread form the thread pool
More info you can find in MSDN
ms-help://MS.MSDNQTR.2003FEB.1033/cpguide/html/cpovrasynchronousprogrammingo
verview.htm
HTH
B\rgds
100
"Jon Skeet" <sk***@pobox.com> wrote in message
news:MP************************@news.microsoft.com ...
grmAbay <gr*****@hotmail.com> wrote: This might sound as a stupid question, but how can I pass parameters to
a thread?
Not a stupid question at all - see
http://www.pobox.com/~skeet/csharp/threadstart.html
--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet/
If replying to the group, please do not mail me too