1
我尝试两次调用,然后再次调用另一个对象。WPF从两个线程调用
public void Show()
{
if (mainGrid == null)
return;
if (!Dispatcher.CheckAccess())
{
Dispatcher.BeginInvoke(new ThreadStart(delegate() { Show(); }), DispatcherPriority.Background);
return;
}
mainGrid.Children.Add(rec);
rec.HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch;
rec.VerticalAlignment = System.Windows.VerticalAlignment.Stretch;
mainGrid.Children.Add(this);
this.HorizontalAlignment = System.Windows.HorizontalAlignment.Center;
this.VerticalAlignment = System.Windows.VerticalAlignment.Center;
}
两个物体B,C继承了这一功能,从A: 当我从过程调用B.show(),然后B.showStop()从线程和C.show()我得到异常使用特权主.children.Add(..)来自C.show() 请帮我解决这个问题。
我删除了第二个方法声明,因为它似乎是完全一样的东西。 (你有意外粘贴两次吗?) –
你得到的实际异常是什么?和'showStop()'的代码是什么? – svick