I write a bootloader in C # and dwell on the following problem: what method should I use to parallelize my downloads and update my GUI?
In my first attempt, I used 4 threads, and upon completion of each of them I started another one: the main problem was that my processor is 100% started every time a new thread starts.
At Google, I discovered the existence of BackgroundWorker and ThreadPool: stating that I want to update my GUI with the progress of each link that I download, what is the best solution?
1) Creating 4 different BackgroundWorker, attaching a delegate to each ProgressChanged event to a function in my GUI to update progress?
2) Use ThreadPool and set the maximum and minimum number of threads for the same value?
If I select # 2 when there are no more threads in the queue, will it stop 4 worker threads? Does he hang them? Since I have to load different link lists (20 links to them) and switch from one to the other at the end, does ThreadPool start and stop threads between each list?
If I want to change the number of worker threads in real time and decide to use ThreadPool, changing them from 10 threads to 6, it throws and excludes and stops 4 random threads?
This is the only part that gives me a headache. I thank each of you in advance for your answers.
source share