I am trying to find a way to add multiple (100+ with high amount of data) controls to a WPF GUI without blocking the GUI thread by itself. That's how i create the controls currently:
I create the controls asynchronous in a parallel thread and i am able to add them to the GUI but when it comes to container.Children.Add() the GUI is blocked.
My first try was creating them by a task in a async method..
var a = Task.Factory.StartNew(() =>
{
foreach (UserElement element in userElements)
this.Dispatcher.Invoke(() => { UserElementsContainer.Children.Add(element); });
});
await a; //Won't work with or without await.
Is there another way?