线程更新UI

public delegate void HandlerLableText(string msg);
void RichTexLableText(string msg)
{
if (this.InvokeRequired)
{
HandlerLableText objRichTextAppendText = new HandlerLableText(RichTexLableText);
IAsyncResult result = this.BeginInvoke(objRichTextAppendText, new object[] { msg });

if (result.CompletedSynchronously)
{
objRichTextAppendText.EndInvoke(result);
}

}
else
{
this.richTextBox1.AppendText(msg);
this.richTextBox1.AppendText(" ");
}
}

原文地址:https://www.cnblogs.com/yufan27209/p/4121937.html