问题的产生
底层采集数据,UI使用ObservableCollection绑定,根据数据绘制曲线,每秒有上千个数据,UI卡顿
问题的原因
ObservableCollection 每次添加数据都会造成UI更新,UI处理不了每秒上千次的更新
问题的解决
定时更新UI ,但ObservableCollection未提供此功能,所幸大牛做了ObservableCollection的延时更新扩展
https://github.com/ENikS/ObservableCollectionEx
但未实现定时功能,自己写了一个类
public class MyObservableCollectionTimer<T>
{
private ObservableCollectionEx<T> Target { get; set; }
private Queue<T> myq = new Queue<T>();
private int maxCount;
private int Interval;
private System.Timers.Timer myTimer;
private bool isRemove = false;
public MyObservableCollectionTimer(ObservableCollectionEx<T> Target,int maxCount,int Interval,bool isRemove)
{
if (Target == null)
{
throw new Argumen