rori Merci de ta patience & de ta réponse c'est sympa
par contre:
Opération inter-threads non valide : le contrôle 'progressBar1' a fait l'objet d'un accès à partir d'un thread autre que celui sur lequel il a été créé.
Avec ton code j'ai été obligé de mettre f en varibale d'instance !
Peut on passer une variable à un thread ??
typiquement un truc du genre:
Thread t = new Thread(new ThreadStart(MyThread), f);
::: EDIT :::
Jvais tester ca et je reviens:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
| static void Main(string[] args)
{
Thread th = new Thread(new ParameterizedThreadStart(Afficher));
Thread th2 = new Thread(new ParameterizedThreadStart(Afficher));
th.Start("A");
//On attend la fin du thread A avant de commencer le thread B.
th.Join();
th2.Start("B");
Console.ReadKey();
}
static void Afficher(object texte)
{
for (int i = 0; i < 10000; i++)
{
Console.Write((string) texte);
}
} |
:::: EDIT2 ::::
Erreur 1 Aucune surcharge pour 'MyThread' ne correspond au délégué 'System.Threading.ParameterizedThreadStart'
je suis en 2.0
::: EDIT 3 :::
J'ai rien dis il faut mettre object en param,
mais j'ai toujours l'erreur:
Opération inter-threads non valide : le contrôle 'progressBar1' a fait l'objet d'un accès à partir d'un thread autre que celui sur lequel il a été créé.
Partager