I've added a Dispatcher and still getting UI freezes after my command executes on a button press.
My current attempted fix
new Thread(() =>
{
Parallel.ForEach(BootstrapNodes,
new ParallelOptions { MaxDegreeOfParallelism = 2 },
(node) =>
{
Console.WriteLine(String.Format("Currently bootstrapping {0} on {1}",
node.NodeName,
node.IPAddress));
ChefServer.BootstrapNode(node);
});
}).Start();
Version that freezes ui
Dispatcher.CurrentDispatcher.Invoke(DispatcherPriority.Background, new Action(() => {
Parallel.ForEach(BootstrapNodes,
new ParallelOptions { MaxDegreeOfParallelism = 2 },
(node) =>
{
Console.WriteLine(String.Format("Currently bootstrapping {0} on {1}",
node.NodeName,
node.IPAddress));
ChefServer.BootstrapNode(node);
});
}));
Do I need to dive deeper into my function calls to avoid UI freezes? I'm trying to avoid spawning threads all over the place.
EDIT: I want to note that my background task is heavily expensive.