Progress Bar

G

Guest

Hi,

I am having a giant headache because a progress bar on a statusStrip.

Ok I will describe all the details to get help from anyone....

I have a MainForm, this form as a a component that is a menuPanel in the
left and content a panel in the right, in the panel I am loading forms...

when I select a item from the menuPanel I dispose the form in the right and
load another...

I added a timer to the main form in order to increment values to the
progress bar while the other forms are loading... and I did the following (it
only a pseudo-code):

onItemClick()
{
timer.Start()
//Dispose and Load the new form
....
timer.Stop()
}

onTick()
{
if (progress.value < progress.maximum)
progress.value+=1
else
progress.value = progress.minimum
}

the problem is that the flow never gets on the onTick method....

Note: the timer IS enabled, and the tick event is associated and the
interval is 1
so there is no reason to this to happen... :(

I don't know how to get around this....

Hints and/or code snippets are wellcome!
 
M

Marc Gravell

IIRC, the timer (and certainly the display) is going to depend on the form's
message queue (could be wrong), so it won't update in a tight method / loop.

You could use the acursed DoEvents(), but I don't recommend it. Since you
are creating UI elements, you can't really use the background thread
trick... (unless you use a background thread to create a second form that
you display with the timer / progress bar, and then close when the primary
UI thread is complete).

Perhaps...

Marc
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top