I have a function, when the function starts, I want to display some UI components and then start working and at the end, I want to erase those components from there. Problem is that I don't see the change in UI on the form.
The function in which I am doing this is:
public void Processor()
{
// ------------- SETTING UI COMPONENTS
lblProgress.Visible = true;
progressBar.Visible = true;
btnStop.Visible = true;
// ------------- WORKING
int counter = 0, percent = 0;
foreach (string url in Urls)
{
.... WORKING THAT TAKES TIME
counter += 1;
percent = ((counter * 100) / Urls.Count());
// ------------- MODIFYING UI COMPONENTS
// Modification doesn't appear on the form while running
lblProgress.Text = "Progress: " + (percent > 100 ? 100 : percent) + "%";
progressBar.Value = percent;
}
// ------------- SETTING UI COMPONENTS
lblProgress.Visible = false;
progressBar.Visible = false;
btnStop.Visible = false;
lblDone.Visible = true;
}
Can someone help with this. Kindly let me know if I am doing something wrong.