Winform中多线程无法访问使用 Control.CheckForIllegalCrossThreadCalls = false;

在winform多线程中,新创建的线程无法访问UI线程创建的窗口控件,设置构造函数

 private void Form1_Load(object sender, EventArgs e)
        {
            Control.CheckForIllegalCrossThreadCalls = false;
        }

Form1.CheckForIllegalCrossThreadCalls = false;

也可以对某一控件进行单独设置

 

posted @ 2021-01-29 10:53  越吃越瘦  阅读(227)  评论(0编辑  收藏  举报