I need to run the same thread/method multiple times at the same time.
What i have it this (Actual Names changed)
foreach (string number in liststrings)
{
ThreadStart work = delegate { Method1(number); };
Thread thr = new Thread(work);
thr.IsBackground = true;
thr.Start();
}
Method1
public static Method1(string numb)
{
Random rnd = new Random();
int threadC = rnd.Next(1,100000);
MessageBox.Show(threadC.ToString());
int i = 1;
while(i==1)
{
//Do Stuff
}
}
It runs multiple threads, let's say three threads for this example. So three messageboxes popup all of them with the same numbers, need it to be different numbers each time.
Thanks for the help!
(c#, winforms)