How to maintain a responsive interface when processing large amounts of data?

I create winform for processing (convert txt files to tiff) a large number of files. I put all the code behind the button (btnProcess). Is that a good idea? This works, but I noticed that when I quit winform and return to this, I see a blank window until the process is complete. I heard about a worker. What is the purpose of the background worker?

+5
source share
3 answers

Here you need multithreading. This means that two (or more) code streams will work in parallel. One of them will be the user interface thread, which is responsible for drawing the window. In your case, you run your code in the user interface thread and thereby block the display of the user interface while your code is running.

The goal of BackgroundWorker is to start an operation on a new thread and this is what you need.

+9
source

BackgroundWorker class

BackgroundWorker , . , (UI), , , . , BackgroundWorker .

BackgroundWorker.

+3

It depends on your application. If it is a single-purpose application that is not extremely long, and the only problem is that the screen does not draw. This is what it seems to me, just throw Application.DoEvents in a loop and do with it.

+2
source

All Articles