0

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.

ProgrammingLlama
  • 36,677
  • 7
  • 67
  • 86
  • 1
    What kind of application is this? How do you define "best way"? Faster than `BackgroundWorker`? Just a newer API? This kind of question has been asked for [WinForms](https://stackoverflow.com/q/25013207/150605), [WPF](https://stackoverflow.com/q/7005193/150605), [Universal Apps](https://stackoverflow.com/q/28979590/150605), and the [TPL](https://stackoverflow.com/q/3513432/150605). – Lance U. Matthews Dec 03 '19 at 07:01
  • This application is a Image Viewer library. It can load one to several dozen image files simultaneously, depending on the view mode. it's a winform library developped in c#. Yes, I'm looking for a new API, and I've heard there are APIs that support multithreading and manage thread pools. – Kyo Joon Lee Dec 04 '19 at 04:35
  • Does this answer your question? [BackgroundWorker alternatives for Windows Forms](https://stackoverflow.com/questions/25013207/backgroundworker-alternatives-for-windows-forms) or [Task parallel library replacement for BackgroundWorker?](https://stackoverflow.com/q/3513432/150605) – Lance U. Matthews Dec 05 '19 at 19:53

0 Answers0