I'm performing some tests with an scrollbar in Winforms. I have the following code, that seems to be correct, but I never see the scrollbar completely fill. When the scrollbar value reaches 100, the scroll draw is as shown in this picture (about 50%).
This is the example code that I'm using:
private void animate_scroll(object sender, EventArgs e)
{
progressBar1.Minimum = 0;
progressBar1.Maximum = 100;
progressBar1.Step = 1;
ThreadPool.QueueUserWorkItem(new WaitCallback(AnimateScroll));
}
private void AnimateScroll(object state)
{
while (true)
{
mValue = (mValue + 1) % 101;
this.Invoke((MethodInvoker)delegate()
{
progressBar1.Value = mValue;
System.Diagnostics.Debug.WriteLine(progressBar1.Value);
});
System.Threading.Thread.Sleep(10);
}
}
private int mValue = 0;