[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 426
  • Last Modified:

progressbar in C#

hi guys,

Im trying to create a progressbar
i tried timer option, it worked but didnt really work as I wanted, because it just keeps iterating until stop.
i want a progressbar that gradually grew up to max value.
the issue now is that the code I need progressbar for is a simple adding printer method.
and how long it takes to finish is up to network.

how can I make a progressbar in this case?
any example?
0
Ikelca
Asked:
Ikelca
  • 2
1 Solution
 
djon2003Commented:
Ehm, from my printer experience, you won't be able to get that time length. So you won't be able to calculate where it is up to.

That's why now some programmers use infinite progress bar which doesn't show a progress but only a running process (when time to accomplish is unknown or no data can be used to establish a maximum).
0
 
IkelcaAuthor Commented:
well, in my case, the time period of adding a printer varies so i still can see the difference,
and i did use timer to create infinite loop progressbar. but i don't really like it.
it works sometime, and sometimes only runs half or something.

in addition, adding a printer is just an example, there are other stuff such as authentication through WLAN in AD and so on. all take sometimes.

also, i have tried using a 2nd background worker, but it seems vc2010 does not allow me adding 2nd.

0
 
djon2003Commented:
From your other usage examples, I see that no definitive time length can be calculated, because (as you also say) it varies through time.

So, in this case, the only way is to advice the user that your program is not crashed and is still executing the task. Otherwise, you could calculate times and store it. With this information, you can average them and use that number as your maximum. So the progress bar would always ends near by the end (either a little before or after, if your lucky, on it). This can be tricky though if erroneous data comes in. This could also be detected, but can more trickier.
0
 
Mike TomlinsonMiddle School Assistant TeacherCommented:
Just set the progressbar to "marquee", which is a built-in "infinite" style.  Move the long tasks to another thread.
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now