I have an ObservableCollection<T>
which will hold a lot of items.
The data will be received async by using a backgroundworker (This works fine and fast).
But if I try to bind the huge collection to a listbox/listview (whatever) at the BackgroundWorkerCompletedTask the visualization will take a lot of time an the GUI will hang until the binding/visulization is completed.
Any ideas how to improve the performance or to prevent that behavior?
void bgGetData_DoWork(object sender, DoWorkEventArgs e)
{
HugeData();
}
void bgGetData_ProgressChanged(object sender, ProgressChangedEventArgs e)
{
devices.Add((ServiceReference1.Device)e.UserState);
}
private void HugeData()
{
foreach (ServiceReference1.Device dev in Proxy.client.GetHugeDate())
{
bgGetData.ReportProgress(0, dev);
}
}
The data is bound by:
myControl.ItemsSource = devices;
Thank you.