Now, we are going to make some changes to the application to provide a more responsive UI running the parallelized loop with an asynchronous execution to unblock the UI thread:
Clickevent in the button butRunBatch and add the following line of code:
// Start the BackgroundWorker (the consumer) bakDisplayImages.RunWorkerAsync();
After the line
praoNebulaFinders = new ConcurrentQueue<NebulaFinder>(); (we want the BackgroundWorker to run concurrently with the parallelized loop).
trycatchblock including the
Parallel.ForEachblock of code with the following (we ...