Click here to Skip to main content
15,900,258 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
C#
        private void button2_Click(object sender, EventArgs e)
        {
//I have a List(List_movieLinks) containing 900 strings.
            for (int i = 0; i < List_movieLinks.Capacity; i++)
            {
//I have a custom control(controlFile1) with a progressBar inside.
                if (controlFile1.ready)
                {
//until the progressBar value = 100 (until is full)
// 5 seconds are passing
// but the for loop is not stopping for those 5 seconds.

// how do I wait the progressBar to finish for every item in the loop? 

                }
            }
         }
//thank you


What I have tried:

C#
yes, it's a progress bar problem after all.
:)
problem solved
I was thinking at the timer element in the same time, but when I narrowed it down to bits, all became clear.
Thank you, all.
Posted
Updated 14-Feb-16 5:40am
v3
Comments
Richard MacCutchan 14-Feb-16 7:59am    
The above code does not explain what is going wrong. The normal use of progress bars is that the underlying code is used to update the bar, not the other way round.
_Q12_ 14-Feb-16 8:06am    
I specified 5 seconds are passing until the progress bar is full.
So, "underlying code to update the progressbar" exist already.
Richard MacCutchan 14-Feb-16 8:12am    
So what exactly is your problem?
_Q12_ 14-Feb-16 10:59am    
I updated the "What I have tried:" thread.
Sascha Lefèvre 14-Feb-16 9:38am    
That's not what Richard exactly meant (pretty sure anyway). Normally the code that does "the work" (doing something with your 900 strings in this case) updates the ProgressBar in certain increments which correlate to the actual progress of the work being done. Your constant 5 seconds don't make much sense. If the work is being done in less than 5 seconds you're waiting for nothing and if it takes longer then what? So drop the "constant time approach" and update your ProgressBar according to the actual progress.

1 solution

are you processing any action/steps in ControlFile under the for loop? If yes then you have to update custome logic a bit to set any flag whether the action withing custom control is finished or not.

add one while loop within if condition and exit when the controlfile.flag is true
 
Share this answer
 
Comments
_Q12_ 14-Feb-16 9:31am    
if (controlFile1.ready) is the flag.
I updated the "What I have tried:" thread.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900