「System.InvalidOperationException」類型的未經處理的異常在 System.Windows.Forms.dll 中發生線程
其餘信息: 線程間操做無效: 從不是建立控件「txtPortName02」的線程訪問它。orm
解決方法:blog
1 構造方法中添加string
CheckForIllegalCrossThreadCalls = false;io
2 方法二 invoke方法
txtPortName02.Invoke(new Action<string>((str) => { label1.Text = str; }), r.Next(0, 10).ToString());im