using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; namespace test { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { System.Threading.Thread.Sleep(10000); } } }
Quelques mots de remerciements seront grandement appréciés. Ajouter un commentaire
117 internautes nous ont dit merci ce mois-ci
public partial class Form1 : Form { Thread _Thread; public Form1() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { if (_Thread == null) { _Thread = new Thread(new ThreadStart(ThreadMethod)); } _Thread.Start(); // attention au 2e appui sur le bouton: quoi faire? } private void ThreadMethod() { // ton analyse ici Thread.Sleep(10000); } }
Quelques mots de remerciements seront grandement appréciés. Ajouter un commentaire
117 internautes nous ont dit merci ce mois-ci
public partial class Form1 : Form { Thread _Thread; public Form1() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { if (_Thread == null) { _Thread = new Thread(new ThreadStart(ThreadMethod)); _Thread.Start(); } } private void ThreadMethod() { // ton analyse ici Thread.Sleep(10000); _Thread = null; } }
Quelques mots de remerciements seront grandement appréciés. Ajouter un commentaire
117 internautes nous ont dit merci ce mois-ci
public void ThreadMethod() { // update UI this.Invoke((MethodInvoker)delegate { label1.Text = "---" + i.ToString(); }); }
Quelques mots de remerciements seront grandement appréciés. Ajouter un commentaire
117 internautes nous ont dit merci ce mois-ci
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; namespace testThread { public partial class Form1 : Form { System.Threading.Thread _Thread; public Form1() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { if (_Thread == null) { _Thread = new System.Threading.Thread(new System.Threading.ThreadStart(ThreadMethod)); _Thread.Start(); } } public void ThreadMethod() { // ton analyse ici for (int i = 0; i < 5; i++) { System.Threading.Thread.Sleep(10000); label1.Text = "---" + i.ToString(); } _Thread = null; } } }
Les membres obtiennent plus de réponses que les utilisateurs anonymes.
Le fait d'être membre vous permet d'avoir un suivi détaillé de vos demandes et codes sources.
Le fait d'être membre vous permet d'avoir des options supplémentaires.