Community discussion forum

Handle Application.DoEvents()

  • 10 months ago
    I've created a windows application which shows change of label text.I use loop to increment value from 1 to 100 and that shows in a label.For showing that I use Application.DoEvents() method.But I need to cancel that operation after clicking on close button.But after I clicking on close button it only close form but not the operation.Also it need to click twice on the "Close" button.Single click doesn't work. namespace TestApp { public partial class FrmTest : Form { public FrmTest() { InitializeComponent(); } private void btnClose_Click(object sender, EventArgs e) { this.Close(); } private void btnProcess_Click(object sender, EventArgs e) { for (int i = 1; i <= 100000; i++) { this.lblText.Text = i.ToString(); Application.DoEvents(); //System.Threading.Thread.Sleep(200); } btnMsg.MouseClick += new MouseEventHandler(btnMsg_Click); } private void btnMsg_Click(object sender, EventArgs e) { MessageBox.Show(sender.ToString()); MessageBox.Show(e.ToString()); } } }
    Post was edited on 20/01/2009 07:42:49 Report abuse

Post a reply

No one has replied yet! Why not be the first?

Sign in or Join us (it's free).

We'd love to hear what you think! Submit ideas or give us feedback