Dave,
If you are using .NET 2.0 (and C# 2.0 as a result), you can use
anonymous delegates to pass whatever parameters you want to your thread.
Say you have a method, DoSomething, like so:
void DoSomething(string param1, string param2, string param3)
{
}
Which is what you want to run on the other thread. You can create the
thread and call it like this:
// The parameters.
string param1 = "Hey";
string param2 = "You";
stirng param3 = "There";
// The delegate to call.
ThreadStart ts = delegate() { DoSomething(param1, param2, param3) };
// The thread.
Thread t = new Thread(ts);
// Run the thread.
t.Start();
Now, the only thing you have to be careful of here is that you don't
change the values of param1, param2 and param3 between the time you set
them, and the time you call Start. If you do, then those values are going
to be changed before the delegate is called, and could affect your program
adversely.
--
- Nicholas Paldino [.NET/C# MVP]
-
mv*@spam.guard.caspershouse.com
"Code Monkey" <dl********@gmail.comwrote in message
news:11*********************@x35g2000prf.googlegro ups.com...
Is there anyway I can start a get a job done by starting a new thread
with MULTIPLE parameters?
>>From what I can see, the BackgroundWorker and ParameterizedThreadStart
operations only take a maximum of 1 parameter?
I need a way of passing (at minimum) at least 3 parameters to the new
thread.
TIA
Dave.