wpf

2개의 LIST 비교 하는것

동동(이재동) 2021. 11. 18. 18:01

private bool IsDiffList<T>(List<T> list1, List<T> list2)
        {
            var diff1 = list1.Except(list2);
            var diff2 = list2.Except(list1);

            var resultDiff = diff1.Concat(diff2).ToList();

            if (resultDiff.Count > 0)
                return true;
            else
                return false;
        }

 

if (IsDiffList<OrderInfo>((xProfitOrderListbox.ItemsSource as List<OrderInfo>).ToList(), _service.OrderInfoList))
                {
                    xProfitOrderListbox.ItemsSource = _service.OrderInfoList;
                    xProfitOrderListbox.Items.Refresh();
                }

 

이런식으로 반복적으로 item을 넣어야 하는곳에 넣어준다. timer를 이용하면 객체를 계속 생성하기때문에

 

무조건 넣어주면 메모리 Leak 이 걸린다. 그렇기 떄문에 변경될때만 적용되게 해야한다.