线程间操作无效: 从不是创建控件的线程访问它
a(this.ViewModel.WhenAnyValue(m => m.Datas).Subscribe(Datas => { try { #region 法一 //new Thread(() => //{ // for (int i = 0; i < Datas.Rows.Count; i++) // { // Action<int> c = new Action<int>(Action2Test); // Invoke(c, i); // } //}).Start(); #endregion #region 法二 //for (int i = 0; i < Datas.Rows.Count; i++) //{ // Action<int> c = new Action<int>(Action2Test); // Invoke(c, i); //} #endregion #region 法三 for (int i = 0; i < Datas.Rows.Count; i++) { this.Invoke(new Action(() => { this.cbCableDataList.Properties.Items.Add(i); })); } #endregion } catch (Exception ex) { throw; } }));
C#.net. WPF.core 技术交流群 群号205082182,欢迎加入,也可以直接点击左侧和下方的"加入QQ群",直接加入