TheSwamp

Code Red => .NET => Topic started by: csharpbird on June 24, 2008, 10:36:46 AM

Title: Why the progressbar step 6%?
Post by: csharpbird on June 24, 2008, 10:36:46 AM
The following code wants the progressbar to step 1% one time.But in fact it step 6% one time.
Code: [Select]
public void Test()
        {
            ProgressMeter p = new ProgressMeter();
            p.Start("Status...");
            p.SetLimit(100);           
            for (int i = 0; i < 100; i++)
            {
                System.Threading.Thread.Sleep(100);
                p.MeterProgress();
            }
            p.Stop();         
        }
Title: Re: Why the progressbar step 6%?
Post by: sinc on June 24, 2008, 11:09:14 AM
It gets done 6x faster that way.   :-)
Title: Re: Why the progressbar step 6%?
Post by: Chuck Gabriel on June 24, 2008, 11:18:12 AM
Shouldn't p.MeterProgress() be p.PerformStep() ?  That should work, assuming you have p.Step = 1
Title: Re: Why the progressbar step 6%?
Post by: New Shooz on June 24, 2008, 05:02:37 PM
maybe it's dyslexic
Title: Re: Why the progressbar step 6%?
Post by: MickD on June 24, 2008, 05:37:29 PM
maybe by the time the PB actually gets re-drawn it has moved 6% ??
Title: Re: Why the progressbar step 6%?
Post by: csharpbird on June 24, 2008, 08:55:57 PM
How to step by 1%?
Title: Re: Why the progressbar step 6%?
Post by: Chuck Gabriel on June 24, 2008, 09:21:30 PM
How to step by 1%?

p.Step = 1;
Title: Re: Why the progressbar step 6%?
Post by: csharpbird on June 25, 2008, 04:30:49 AM
There is no Step property for ProgressMeter
Title: Re: Why the progressbar step 6%?
Post by: Chuck Gabriel on June 25, 2008, 06:58:36 AM
There is no Step property for ProgressMeter

 :oops:

Sorry about that.  I misread the code in the first post.  I thought you were using a ProgressBar.
Title: Re: Why the progressbar step 6%?
Post by: Alexander Rivilis on June 25, 2008, 07:34:20 AM
Try: System.Threading.Thread.Sleep(1000);
Title: Re: Why the progressbar step 6%?
Post by: Chuck Gabriel on June 25, 2008, 07:56:21 AM
Have you read Kean Walmsley's blog post on this subject?  http://through-the-interface.typepad.com/through_the_interface/2007/05/displaying_a_pr.html

Skip through all the pInvoke stuff down to where it says "Update," and he gets into how to work with the managed ProgressMeter class.  He throws an Application.DoEvents() into the end of the loop to "allow AutoCAD to repaint."  Makes me think maybe MickD was on the right track.
Title: Re: Why the progressbar step 6%?
Post by: csharpbird on June 25, 2008, 08:34:25 AM
Have you read Kean Walmsley's blog post on this subject?  http://through-the-interface.typepad.com/through_the_interface/2007/05/displaying_a_pr.html

Skip through all the pInvoke stuff down to where it says "Update," and he gets into how to work with the managed ProgressMeter class.  He throws an Application.DoEvents() into the end of the loop to "allow AutoCAD to repaint."  Makes me think maybe MickD was on the right track.
Yes.
P/Invoke is OK.
But with the managed ProgressMeter class,the progress bar can not step smoothly.