I’m using progress bar of WPF (C#) to describe the process’s progress.
My algorithm is below:
DoSomethingCode1();
ProgressBar.SetPercent(10); // 10%
DoSomethingCode2();
ProgressBar.SetPercent(20); // 20%
...
DoSomethingCode10();
ProgressBar.SetPercent(100); // 100%
It’s ok, but it will make the progress bar was not sequent.
Someone can tell me some suggestions that make the progress bar is updated softly?
You could call the
BeginAnimationmethod to animate theProgressBar‘sValueproperty. In my example below, I used aDoubleAnimation.I created an extension method that takes in the desired percentage:
So in your code you could simply call:
Doing this simply smooths out the transition so it looks nicer. To quote another answer: “The idea is that a progress bar reports actual progress – not time elapsed. It’s not intended to be an animation that just indicates something is happening.” However, the default style of the progress bar does have a pulsating effect which can imply work is happening.