I am facing a problem in c#.
I have a form: Form1. The Form1 has a button which executes a loop in selenium c#. While this is running, the form freezes.
I want to show the progress (like 1/100, 2/100, ...) in a progressBar (progressBar1) in the same form. This value changes in the loop but does not show up in the UI, till the loop has finished. How do I achieve this?
--EDIT-- This question is about how to run the foreach loop in background so that the UI still responds. The form has more buttons and stuff, so the UI should be updated as well as the user should have access to other buttons. this cannot be possible is the loop freezes the program.
This is my code:
foreach (// condition)
{
//do something
//increment progress
progressBar1.Value++;
}