Best performance for ObservableCollection.AddRange

霸气de小男生 提交于 2019-12-05 12:19:07

Given that Concat<T> is an extension method it is almost certainly just calling .Add() under the covers, it can't have internal knowledge of the class. You could use ildasm.exe to see what's going on for sure.

I hit performance issues for this very case using ObervableCollection<T> a few years ago. The solution I eventually arrived at was to implement IList<T> and INotifyCollectionChanged with a custom implementation that supports raising a single CollectionChanged event with an actual collection delta (instead of per-item events) in response to a call to AddRange<T>. Check out the documentation for NotifyCollectionChangedEventArgs to get the details.

http://msdn.microsoft.com/en-us/library/system.collections.specialized.notifycollectionchangedeventargs(v=vs.110).aspx

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!