My question is how to update UI controls (such as ProgressBar) from another thread while UI thread is busy for querying the database (running a time-consuming stored procedure) ?
I checked these questions and still no solution is found for me.
- Updating UI continuously while the main thread is busy
- How to update the GUI from another thread in C#?
- Run multiple UI Threads
- Cross-thread cross-form. Display a splash screen with a progress bar
I know one option is to do time-consuming work using BackgroundWorker and update ProgressBar using ReportProgress method, but I have a problem in this option because the UI thread is responsible for instantiate and show another form after querying the database like this:
Form2 f2=new Form2();
f2.show();