【发布时间】:2011-03-28 19:30:22
【问题描述】:
我正在使用 .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 不喜欢另一个线程访问创建它的对象以外的对象。但是,我认为肯定有比进行如此多的调度程序调用更好的方法,是否有人至少可以将我推向正确的方向(如果有更好的解决方案)。
【问题讨论】:
标签: c# wpf multithreading dispatcher