[.NET] Progress Bars + Timers

Soldato
Joined
12 Jun 2005
Posts
5,361
Hi there,

I am waiting to use one of the progress bar objects to show how much complete the web browser has loaded and also how much complete the commands are when a certain button is pushed.

Also I have some text which appears and i want it to dissapear after a set time.

I am doing VB.NET but i am sure it will be pretty similar for all the .NETS

How would i do these, or does anyone have a web tutorial for these?

Thanks.
 
progress bars can be tricky,

Basically you need to fire an event in the worker thread every time progress has increased my a known amount, then handle this event in the GUI thread to increment the progress bar. You'll need to know before hand how many units you want to have available in the progress bar and send an event each time a unit of work has been done by the worker thread.

There is a tutorial linked to in the MSDN library page on the progress bar component iirc.

What do you mean your UI/worker processes aren't in different threads? You'll need to look at that first!

HT
 
progress bars are pretty easy to use.

Ive got one in a vb.net app but theyre similar in c# or whatever.

Anyway, put the control on your form, set its maximum property to something like 100 then when you want to increment it do

progressbar1.value = <something between 1 and 100>

and away it goes.

It should be pretty easy to work out how much of an increment you need to add to it in each loop. eg If your processing a recordset you would just take the number of records, divide by 100 (100 being the maximum value you just set in the properties) and thats your increment
 
Ok, I have decided to scratch the whole progress Bar idea, but i still need help on the text bit.

How do i do it so i set the text of a label, then after 5 seconds it sets the text of the label to null.
 
NumptyUK said:
progress bars are pretty easy to use.

Ive got one in a vb.net app but theyre similar in c# or whatever.

Anyway, put the control on your form, set its maximum property to something like 100 then when you want to increment it do

progressbar1.value = <something between 1 and 100>

and away it goes.

It should be pretty easy to work out how much of an increment you need to add to it in each loop. eg If your processing a recordset you would just take the number of records, divide by 100 (100 being the maximum value you just set in the properties) and thats your increment

It's usually not as simple as that, because things that you typically want to show progress for work are also the things you typically give their own threads.

BackgroundWorker solves this problem :)
 
How would i make ssure something completes its task before it moves on?

Basically I need a web drowser to load the page before it moves onto the next command?

how would i do this?

Could you do this as it does not appear to work for me:

Code:
            Do While Not Web.ReadyState = WebBrowserReadyState.Complete
            Loop
 
Last edited:
Back
Top Bottom