By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,694 Members | 1,332 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,694 IT Pros & Developers. It's quick & easy.

Pop UP Progress Bar REPOST

P: n/a
I am trying to create a pop up progress bar (on a form) that would show
progress from downloading files from an FTP server.

any help will be appreciated
Nov 20 '05 #1
Share this Question
Share on Google+
8 Replies


P: n/a
In article <E9lab.38516$Cu3.4173@edtnps84>,
di*************@rivusglobal.com says...
I am trying to create a pop up progress bar (on a form) that would show
progress from downloading files from an FTP server.

any help will be appreciated


Put the FTP transfer in a different thread and have it raise events as
it downloads (perhaps raise an event every 8k downloaded). Have your
main form subscribe to this event and update your progress bar.

The key thing here is that the UI update has to be done on the main
thread (the one started by the runtime) since Windows Forms controls are
not thread-safe.

--
Patrick Steele
Microsoft .NET MVP
http://weblogs.asp.net/psteele
Nov 20 '05 #2

P: n/a
"Dino M. Buljubasic" <di*************@rivusglobal.com> schrieb
I am trying to create a pop up progress bar (on a form) that would
show progress from downloading files from an FTP server.

any help will be appreciated


Which question do you have? How to download the file? How to show the
progress bar?
--
Armin

Nov 20 '05 #3

P: n/a
Hi Patrick,

I'm fairly new to threading, but I had the impression that events couldn't
(or weren't supposed to) be used between threads -- that only Invoke and
BeginInvoke should be used to pass messages between threads. There's a
discussion of UI/worker threading issues in this article, with sample code
that uses Invoke and BeginInvoke as a clunky workaround:

http://msdn.microsoft.com/library/de...et09272002.asp

Am I wrong -- can events safely be used instead?

--Robert Jacobson
"Patrick Steele [MVP]" <pa*****@mvps.org> wrote in message
news:MP************************@msnews.microsoft.c om...
In article <E9lab.38516$Cu3.4173@edtnps84>,
di*************@rivusglobal.com says...
I am trying to create a pop up progress bar (on a form) that would show
progress from downloading files from an FTP server.

any help will be appreciated


Put the FTP transfer in a different thread and have it raise events as
it downloads (perhaps raise an event every 8k downloaded). Have your
main form subscribe to this event and update your progress bar.

The key thing here is that the UI update has to be done on the main
thread (the one started by the runtime) since Windows Forms controls are
not thread-safe.

--
Patrick Steele
Microsoft .NET MVP
http://weblogs.asp.net/psteele

Nov 20 '05 #4

P: n/a
I don't know how to show progress bar. Actaully, I am showing it now but it
does not refresh.

I have a separate form that holds progress bar. My progress bar is updated
inside a separate thread but only what I manage to update is the forms
title. Any controls inside the form such as the progress bar or labels
displaying name of the file being downloaded, are not refreshed.
"Armin Zingler" <az*******@freenet.de> wrote in message
news:ei**************@TK2MSFTNGP11.phx.gbl...
"Dino M. Buljubasic" <di*************@rivusglobal.com> schrieb
I am trying to create a pop up progress bar (on a form) that would
show progress from downloading files from an FTP server.

any help will be appreciated


Which question do you have? How to download the file? How to show the
progress bar?
--
Armin

Nov 20 '05 #5

P: n/a
OK, I understand that. Only one more thing, how to make it reaise event
when it has downloaded 8 or so kb?

I have a sub DownloadFile that downloades file from FTP server, but don't
know how to check for the number of bytes downloaded and then reaise event
while it downloads the bytes.

Thank you for your help
--
Dino Buljubasic
Software Developer
http://rivusglobal.com

"Patrick Steele [MVP]" <pa*****@mvps.org> wrote in message
news:MP************************@msnews.microsoft.c om...
In article <E9lab.38516$Cu3.4173@edtnps84>,
di*************@rivusglobal.com says...
I am trying to create a pop up progress bar (on a form) that would show
progress from downloading files from an FTP server.

any help will be appreciated


Put the FTP transfer in a different thread and have it raise events as
it downloads (perhaps raise an event every 8k downloaded). Have your
main form subscribe to this event and update your progress bar.

The key thing here is that the UI update has to be done on the main
thread (the one started by the runtime) since Windows Forms controls are
not thread-safe.

--
Patrick Steele
Microsoft .NET MVP
http://weblogs.asp.net/psteele

Nov 20 '05 #6

P: n/a
Why don't you use a UserControl, where you'll have the progress bar along
with other label or text.....


"Dino M. Buljubasic" <di*************@rivusglobal.com> wrote in message
news:7g********************@news2.telusplanet.net. ..
I don't know how to show progress bar. Actaully, I am showing it now but it does not refresh.

I have a separate form that holds progress bar. My progress bar is updated inside a separate thread but only what I manage to update is the forms
title. Any controls inside the form such as the progress bar or labels
displaying name of the file being downloaded, are not refreshed.
"Armin Zingler" <az*******@freenet.de> wrote in message
news:ei**************@TK2MSFTNGP11.phx.gbl...
"Dino M. Buljubasic" <di*************@rivusglobal.com> schrieb
I am trying to create a pop up progress bar (on a form) that would
show progress from downloading files from an FTP server.

any help will be appreciated


Which question do you have? How to download the file? How to show the
progress bar?
--
Armin


Nov 20 '05 #7

P: n/a
In article <eU*************@tk2msftngp13.phx.gbl>,
rj**********************@nospam.com says...
I'm fairly new to threading, but I had the impression that events couldn't
(or weren't supposed to) be used between threads -- that only Invoke and
BeginInvoke should be used to pass messages between threads. There's a
discussion of UI/worker threading issues in this article, with sample code
that uses Invoke and BeginInvoke as a clunky workaround:

http://msdn.microsoft.com/library/de...et09272002.asp

Am I wrong -- can events safely be used instead?


Actually, with Windows Forms, you always want to use the
Invoke/BeginInvoke to make sure the code runs on the UI thread.

In fact, that is an easire solution to Dino's problem. Simply had a
reference to the ProgressBar in the FTP code and use BeginInvoke to fire
off any updates on the UI thread.

--
Patrick Steele
Microsoft .NET MVP
http://weblogs.asp.net/psteele
Nov 20 '05 #8

P: n/a
In article <ml********************@news2.telusplanet.net>,
di*************@rivusglobal.com says...
OK, I understand that. Only one more thing, how to make it reaise event
when it has downloaded 8 or so kb?

I have a sub DownloadFile that downloades file from FTP server, but don't
know how to check for the number of bytes downloaded and then reaise event
while it downloads the bytes.


If you're downloading the file, you must be in a loop somewhere pulling
the data over the port. In there, keep a counter going and after 8k
comes down, update the progressbar.

Also, from Robert Jacobson's reply, the easiest way to get the
ProgressBar update would be to:

1) Put the FTP code in a differen thread.
2) Make sure the FTP code has a reference to the progessbar
3) Use BeingInvoke on the progress bar to update it from the FTP thread.

--
Patrick Steele
Microsoft .NET MVP
http://weblogs.asp.net/psteele
Nov 20 '05 #9

This discussion thread is closed

Replies have been disabled for this discussion.