Click here to Skip to main content
15,910,980 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi all,
I have little question that may get any programmer while using progressbar,
Lets consider following scenerio,

int j;
for(float i=0;i<1526974569745878;i++)
{
   SUM=SUM+i+j;
   j++;  
}

This loop may get 6 minute to execute.
so i want do same execution With progress bar increament.
that after some looping a progress bar increase like wise.
NOTE:<br />
1)"1526974569745878" not constant may change time to time.<br />
2)I implemented this by using OnTimer() message handler but not working.<br />
Once execution enter in loop OnTimer() function is not called.<br />

______________________________________________________________________
ALL LINK,CODE,HELPS ARE WELCOME
Posted
Comments
Sandeep Mewara 24-May-11 6:24am    
Tried to search/look for it here at CP articles and already asked questions?

m_progressInit.SetRange32( 0, PROGRESS_BAR_RANGE );
// PROGRESS_BAR_RANGE (Any Integer value)
if(i%1000 == 0)
{
   if(m_progressInit.GetPos() < PROGRESS_BAR_RANGE)
    {
        m_progressInit.StepIt( );
    }
    else
        m_progressInit.SetPos(0);
}
 
Share this answer
 
You have to use separate thread for this,
Just check this Multithread article which exactly simulates your problem.

http://www.codeguru.com/cpp/w-p/system/threading/article.php/c16423/The-Practical-Guide-to-Multithreading---Part-1.htm[^].
 
Share this answer
 
If this is done in the same thread as any other code, it'll block out anything else from occurring. You should reconsider doing this or figure out a better way of accomplishing what you need (threading is definitely one way).
 
Share this answer
 

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