AddRange ObservableCollection问题

时间:2016-04-11 22:00:20

标签: vb.net performance mvvm observablecollection inotifycollectionchanged

您好我正在使用此链接来实现最快的Observable Collection Best performance for ObservableCollection.AddRange

ObservableCollection Doesn't support AddRange method, so I get notified for each item added, besides what about INotifyCollectionChanging?

但是多次调用AddRange()或ReplaceRange()方法时,性能会变慢,例如

AddRange() executed first time in 0.5 sec.
AddRange() executed 2nd Time in 1 sec.
AddRange() executed 3rd Time in 2.5 sec.

即使使用相同的数据,它也会花更多的时间来执行方法。

为了更好地理解,这是一个代码

For Each serie In SeriesList
serie.SeriesDisplayName = "New Series " +    newSeriesCounter.ToString()

 If newSeriesCounter = 1 Then
 serie.Items(1).Number = 500
 End If

 newSeriesCounter += 1
 Next

 Series.Clear()
 Series.AddRange(SeriesList)

0 个答案:

没有答案