Author Topic: Why the progressbar step 6%?  (Read 3590 times)

0 Members and 1 Guest are viewing this topic.

csharpbird

  • Newt
  • Posts: 64
Why the progressbar step 6%?
« 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();         
        }
« Last Edit: June 24, 2008, 08:46:50 PM by csharpbird »

sinc

  • Guest
Re: Why the progressbar step 6%?
« Reply #1 on: June 24, 2008, 11:09:14 AM »
It gets done 6x faster that way.   :-)

Chuck Gabriel

  • Guest
Re: Why the progressbar step 6%?
« Reply #2 on: June 24, 2008, 11:18:12 AM »
Shouldn't p.MeterProgress() be p.PerformStep() ?  That should work, assuming you have p.Step = 1
« Last Edit: June 24, 2008, 12:13:25 PM by Chuck Gabriel »

New Shooz

  • Guest
Re: Why the progressbar step 6%?
« Reply #3 on: June 24, 2008, 05:02:37 PM »
maybe it's dyslexic

MickD

  • King Gator
  • Posts: 3636
  • (x-in)->[process]->(y-out) ... simples!
Re: Why the progressbar step 6%?
« Reply #4 on: June 24, 2008, 05:37:29 PM »
maybe by the time the PB actually gets re-drawn it has moved 6% ??
"Programming is really just the mundane aspect of expressing a solution to a problem."
- John Carmack

"Short cuts make long delays,' argued Pippin.”
- J.R.R. Tolkien

csharpbird

  • Newt
  • Posts: 64
Re: Why the progressbar step 6%?
« Reply #5 on: June 24, 2008, 08:55:57 PM »
How to step by 1%?

Chuck Gabriel

  • Guest
Re: Why the progressbar step 6%?
« Reply #6 on: June 24, 2008, 09:21:30 PM »

csharpbird

  • Newt
  • Posts: 64
Re: Why the progressbar step 6%?
« Reply #7 on: June 25, 2008, 04:30:49 AM »
There is no Step property for ProgressMeter

Chuck Gabriel

  • Guest
Re: Why the progressbar step 6%?
« Reply #8 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.

Alexander Rivilis

  • Bull Frog
  • Posts: 214
  • Programmer from Kyiv (Ukraine)
Re: Why the progressbar step 6%?
« Reply #9 on: June 25, 2008, 07:34:20 AM »
Try: System.Threading.Thread.Sleep(1000);

Chuck Gabriel

  • Guest
Re: Why the progressbar step 6%?
« Reply #10 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.

csharpbird

  • Newt
  • Posts: 64
Re: Why the progressbar step 6%?
« Reply #11 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.