mmmhhh .... avevo pensato ad una cosa più tipo così:
codice:
public partial class Form1 : Form
{
List<System.Threading.Thread> Threads;
private Int32 Contatore = 0;
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
System.Threading.Thread t1 = new System.Threading.Thread(new System.Threading.ThreadStart(StartThreads));
t1.Start();
}
public void StartThreads()
{
Threads = new List<System.Threading.Thread>();
Threads.Add(new System.Threading.Thread(new System.Threading.ThreadStart(Frame1)));
Threads.Add(new System.Threading.Thread(new System.Threading.ThreadStart(Frame2)));
Threads.Add(new System.Threading.Thread(new System.Threading.ThreadStart(Frame3)));
Threads.Add(new System.Threading.Thread(new System.Threading.ThreadStart(Frame4)));
while (true)
{
if (Contatore == Threads.Count)
{
MessageBox.Show("Tutti i Thread Eseguiti");
return;
}
if (Threads[Contatore].IsAlive != true)
{
Threads[Contatore].Start();
}
}
}
public void Frame1()
{
MessageBox.Show("Thread1 Started");
Contatore += 1;
}
public void Frame2()
{
MessageBox.Show("Thread2 Started");
Contatore += 1;
}
public void Frame3()
{
MessageBox.Show("Thread3 Started");
Contatore += 1;
}
public void Frame4()
{
MessageBox.Show("Thread4 Started");
Contatore += 1;
}
}
Ciao!!