Application.DoEvents ou pas ?
j'ai écrit un bout de code :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45
| using System;
using System.Windows.Forms;
namespace eventCountTo
{
public partial class Form1 : Form
{
private CountTo c = new CountTo();
public Form1()
{
InitializeComponent();
c.NumberReached += new NumberReachedEventHandler(c_NumberReached);
c.OnProgess += new NumberOnProgressHandler(c_OnProgess);
c.OnTwo += new NumberIsTwoMumtiplyHandler(c_OnTwo);
}
void c_OnTwo(object sender, MultiplyEventArgs e)
{
lblMultiple.Text = String.Format("{0} est un multiple de deux", e.multiplier);
lblMultiple.Refresh();
//Application.DoEvents();
}
void c_OnProgess(object sender, NumberOnProgressEventArgs e)
{
lblResult.Text = e.position.ToString();
lblResult.Refresh();
//Application.DoEvents();
}
void c_NumberReached(object sender, NumberReadEventArgs e)
{
lblResult.Text = String.Format("{0} reached from {1} ", e.nFin,e.nDebut);
}
private void button1_Click(object sender, EventArgs e)
{
Cursor.Current = Cursors.WaitCursor;
c.NumberToGO(Convert.ToInt32(txtDebut.Text), Convert.ToInt32(txtFin.Text));
Cursor.Current = Cursors.Default;
}
}
} |
avec ou sans cet Application.DoEvents je ne vois pas la différence, est-ce important ? Faut-il le mettre et pourquoi ?
Merci de votre aide :)