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.
source
share