This code will show you how I started multiple threads:
for (int i = 0; i < 8; i++)
{
doImages = new DoImages(this, TCPPORT + i);
var thread = new Thread(doImages.ThreadProc);
thread.Name = "Imaging";
var param = (i + 1).ToString();
thread.Start(param);
}
Now I’m trying to stop the threads before closing my application but I don’t know how to do that?
One simple option is to store references to all of the threads that you spawn and then join all of them when you are done:
This will wait for all of the threads to finish before the application terminates.