-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Description
Hi,
I have an ObservableCollection with 4 lakhs unique items. On a button click event, I execute a Linq Where query to set value for a bool value in the items of the collection.
`
List DistinctCollection = new List();
List filteredCollection = new List();
for(int i=1;i<=400000; i++)
{
DistinctCollection.Add(new DataClass() { Content = i.ToString() });
}
filteredCollection = DistinctCollection.Where(x => x.Content.Contains("2")).ToList();
private void button1_Click(object sender, EventArgs e)
{
// The problem occurs here.
DistinctCollection.Where(x => filteredCollection.Contains(x)).Select(x => x.IsSelected = true).ToList();
DistinctCollection.Where(x => !filteredCollection.Contains(x)).Select(x => x.IsSelected = false).ToList();
}
`
Please use below given sample application to reproduce the problem.
The query works properly when the number of items in the collection is less. But the UI freeze when executing the query if the collection contains 4 lakhs and above items. Is there any possible way to improve the performance of this query?
Thanks in advance.