Cross-thread operation not valid: Control 'txtMessage' accessed from a thread other than the thread it was created on.

发布时间 2023-06-30 10:04:55作者: hofmann

Winform TextBox

 

Cross-thread operation not valid: Control 'txtMessage' accessed from a thread other than the thread it was created on.

 

(330条消息) 解决Cross-thread operation not valid的问题_GuanXX的博客-CSDN博客

 

 

 private void safeSetText(string text) {
            if (this.InvokeRequired) {
                _SafeSetTextCall call = delegate(string s) {
                    this.textBox1.Text = s;
                };
 
                this.Invoke(call, text);
            }
            else
                this.textBox1.Text = text;
        }
 
        private delegate void _SafeSetTextCall(string text);