Interesting Connundrum - Progress Max On the Fly

JaedenRuiner

Well-known member
Joined
Aug 13, 2007
Messages
340
Programming Experience
10+
Well,

This is more of a "If you think it would be an interesting puzzle to play with."

I've been working on it for a while and tried different things, none of which seem to work out right, and perhaps someone else has already played with this and has the awesome solution, as this is probably more math than anything else.

Progress Meters. Simple computation, CurrentItems over MaxItems equals a Percent. Not too difficult. But what if you don't know the MaxItems exactly?

I have 16 Stages within my Applications Operation, and at the onset of each stage I know the "Max" for that stage, which I enter into _stageMaxs array (strangely enough :D)

I've tried:
VB.NET:
Max = _stageMaxs.Sum * (_stageMaxs.Length - CurrentStage)
so basically when the First stage is known to have a max of say 5000, at first my max starts out as 5000 * 16, but when stage 2 is executed, which is say 4000, it becomes 9000 * 15...you get the picture.
This worked a little, but it ended up being very over balanced...shifting from 47% to suddenly 97% between the last two stages. Wasn't very smooth.

I've Also Tried:
VB.NET:
Max = (_stageMaxs.Sum * _stageMaxs.Length) \ CurrentStage
Granted I did the appropriate DivByZero checks and all, but for the math, this one had other problems, like, jumping about from 40% to 23% then upto 63% then back down to 33%....oivay.

These are all based on SQL Statments and the relevant counts associated with them, So I do know at each stage exactly how many are going to be altered, changed, inserted, etc. In Some stages, there are two or three commands, so for those situations the when the subsequent commands are executed, their individual counts are just added to the _stageMaxs(CurrentStage).

The 16 Stages are as follows:
  1. SelectInto - About 3000-5000
  2. Update (Twice) About 3000-5000 Each
  3. SelectInto - Can be 0 and usually is, but sometimes may have a couple
  4. Delete - Same as Stg 3
  5. SelectInto - 75%-95% of 1
  6. SelectInto - 1% of Stg 5, maybe, can be 0, but is usually like 10
  7. Delete (Thrice) Same as Stg 6, but Stg 6 is a < 0, where 7 is <= 0 Where clause
  8. SelectInto - Up To 10% of Stg5, can be 0, but is often a couple 100
  9. Delete(Twice) - First = Stg8, second can be a little more Due to the difference between GroupBy Sums()
  10. Insert Into (XLS File) = Remainder in Table from Stg1 after Stg6-Stg9 Processing
  11. Insert Into (XLS File) = Stg3, if 0 the Export doesn't occur
  12. Insert Into (XLS File) = Stg6, if 0 the Export doesn't occur
  13. Insert Into (XLS File) = Stg8, if 0 the Export doesn't occur
  14. Insert Into = Remainder in Table from Stg5 after Stg6-Stg9 Processing
  15. Select (Used by an Adapter to file a DataTable) - Distinct from Stg14 so About 1/3 of Stg14
  16. Processing Stage = Stg13

The processing stage is rather complicated, but without the hairy details of how many Updates/Summations and Inserts are made in that stage, I know the count will always be the same as Stage 13 prior to it, so I have the Max before the stage begins.

Now all I'm trying to find is an adequate computation to apply to the sum of all the stages in sequence as they are computed, in order to guesstimate the MaxItems until such time as I reach Stage 16 and Have the actual Max there.

Thanks, :)
 
I've ran into situations like this in the past; and rather than using a magical math guesstimate formula to prevent the progress bar from jumping around, I'd recommend you:

1. Create a label stating Step X of 16 and the description of the step.

2. Depending on your needs either set the progress bar to go from 0 to 100% for each stage or let each stage be 6.25% of the total progress bar.
 
I've ran into situations like this in the past; and rather than using a magical math guesstimate formula to prevent the progress bar from jumping around, I'd recommend you:

2. Depending on your needs either set the progress bar to go from 0 to 100% for each stage or let each stage be 6.25% of the total progress bar.

Hrm. I didn't think of that. Basically making the Progress bar 0-1600 (instead of 0 to 100) and thus each stage's Percent (0 - 100) is the over all progress instead of doing each stage's Cur/Max as part of the Total Cur/Max.

Smooth, I like that idea...thanks
 
In these situations I like to use 2 progress bars one for overall and one for the current process (stage).
 
Back
Top