开发者

How to wait for Textbox to finish rendering?

In my program, I append text to a textbox and my program proceeds onward before the textbox finishes rendering. This is bad karma to the user.

To demonstrate this issue, I have written to the System.Console and I see many text lines displayed in the MS Visual C# Express console tab before the text is displayed in the control (in my application).

I have tried Textbox.Update() with no luck, program keeps executing. Textbox.Refresh() does not help either.

How do I get a thread (the GUI or another thread) to wait until the Textbox has finished rendering?

I want to perform the foll开发者_StackOverflow中文版owing (in psuedo code):

Textbox.AppendText("New text\r\n");

// Execution blocked until Textbox finishes drawing.
Textbox.WaitForRenderingToFinish();


What happens if you do

Textbox.AppendText("New text\r\n");
Application.DoEvents();

As discussed in this previous post: How to force Buttons, TextBoxes to repaint on form after a MessageBox closes in C# it is not good practice to do work on the UI thread. Is this what you are doing? Is the entire UI unresponsive as you are proceeding with the program execution, or is it just the textbox that won't update?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜