C# 托管

it2024-01-08  70

项目有一个需求,在线程中给控件赋值报错了

百度后需要托管

delegate void RichTextBoxItem(string sRes); public void AddItemRichTB(String sRes) { if (this.richTextBox1.InvokeRequired) { RichTextBoxItem r = new RichTextBoxItem(AddItemRichTB); this.Invoke(r, new object[] { sRes }); } else { richTextBox1.Text = sRes; } } void Thr() { while(true) { ... AddItemRichTB("Foder Not Exist"); ... } }

 

最新回复(0)