Hello,
I'm working in C# and WPF, very new to both.
I have a loop that reads plenty of data from an external source. The process takes about 20 seconds, and I want to show the progress to the user. I don't need any fancy progress bars, so I chose to plot my progress in a label that will say "Step 1/1000", then change to "Step 2/1000" etc.
My code looks something like this:
// "count" is the number of steps in the loop,
// I receive it in previous code
String countLabel = "/"+count.ToString();
for (i = 0; i < count; i++)
{
... do analysis ...
labelProgress.Content = "Step "+i.ToString()+countLabel
}
However, during that analysis the screen is "stuck" and the progress does not show as advancing. I understand this behavior from my past in C++, where I would probably have a separate thread showing a progress bar receiving notifications from the loop, or some form of repaint/refresh, or forcing the window/app to process its message queue.
What's the right way to do it in C#? I'm not tied to the label, so if there's a simple progress-bar popup screen I could use instead of this label it would also be great...
Thanks