Doug Null
Doug Null

Reputation: 8327

how to immediately update displayed textbox before a long loop

My event handler UIButton440_TouchUpInside( UIButton sender ) updates my TextBox.Text then does a long loop, then returns. But Textbox doesn't update until after return.

How can I display the updated TextBox immediately?

(Like vb.net does with application.doEvents)

Upvotes: 0

Views: 658

Answers (2)

C. Augusto Proiete
C. Augusto Proiete

Reputation: 27878

Assuming you're using Windows Forms, you can call the Update method on the TextBox to force a refresh.

yourTextBox.Update();

Upvotes: 1

Felipe Martins
Felipe Martins

Reputation: 184

You can try firing a thread to do your long loop. I usually like using workers for that, something like this:

        txt.Text = "abc";
        BackgroundWorker worker = new BackgroundWorker();

        worker.DoWork += (o, ea) =>
        {
            //Long loop
        };
        worker.RunWorkerCompleted += (o, ea) =>
        {
            //Do something when the loop ends
        };
        worker.RunWorkerAsync();

Upvotes: 3

Related Questions