I used backgroundworkers because it took a long time to load image files into my image viewer program. The image viewer can load and display multiple images at the same time, running the backgroundworker as many as the number of images in the viewer and saving them in a backgroundoworker collection named bgws. And in the backgroundWorker1_RunWorkerCompleted method,
bgws.Remove (worker);
if (bgws.Count == 0)
{
isLoaded = true;
}
In this way, we make sure that all threads are terminated. Of course, I know this is an old method, and I would like advice from someone who knows what is the latest method and how to use it.