我正在使用.NET 3.5。
我正在为一个项目制作一个WPF应用程序,我想了解一些关于Dispatcher和多线程的见解。这是我的程序示例:
Application.Current.Dispatcher.Invoke(DispatcherPriority.Background, new Action(
() =>_aCollection.Add(new Model(aList[i], aSize[i]))));
Application.Current.Dispatcher.Invoke(DispatcherPriority.Background, new Action(
() => _Data.Add(new DataPoint<double, double>(Id, aList[i]))));
Application.Current.Dispatcher.Invoke(DispatcherPriority.Background, new Action(
() => _historical[0].Add(aList[i])));
我知道WPF不喜欢其他线程访问除创建它的对象之外的对象。然而,我认为一定有比频繁使用调度程序调用更好的方法,请问是否有更好的解决方案,如果有,请指点一下。