Howdy,
You must use constructor accepting ParameterizedThreadStart delegate:
private void Whatever()
{
Thread thread = new Thread(new
ParameterizedThreadStart(this.ThreadProc));
int p1 = 10;
string p2 = "parameter2";
object[] parameters = new object[] { p1, p2 };
thread.Start(parameters);
}
private static void ThreadProc(object parameters)
{
object[] parameterArray = (object[]) parameters;
int p1 = (int)parameters[0];
string p2 = (string)parameters[1];
}
--
Milosz
rkbnair said:
How can I pass a parameter to a new thread?
Thread t = new Thread(new ThreadStart(ThreadProc));
t.Start();
Thread.Sleep(0);