Hi I want to create a new thread for each item in a numericupdown. I want each thread to perform an object. I have this code, but Im not sure if its correct. Please check:

for (int i = 0; i < numericUpDown1.Value; i++)
{

Thread t = new Thread(new ParameterizedThreadStart(myParamObject));
t.Start();


}

Also, another question I have is Im calling a listBox created in another thread so how can I incorporate it so I wont get a cross thread error?

It will work but your threads will go out of scope as soon as the for statement is done. You are also starting them as foreground threads which means your program won't close until they are done. If that's the behavior you want, then you are good. But I'd look into Parallel.For() as it attempts to optimize thread usage based on your systems processor and capabilities.

As for using the ListBox from another thread, read this.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.