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

Label.Text refresh .... ?

P: n/a
When the user clicks the download button I am changing the text of a label
control and do download operation.

The download part of the code makes the application appears like stop
responding.

My question is how to refresh the windows form right after changing the
label text.

I am talking about VB.Net desk top application developed using .Net
Framework 1.1

Thanks,

Smith
Nov 21 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
I am not sure if I really understand your post, but if you click a button to
download something & then try to update a label. Am I right? If so, run your
download from a new thread & then update your label text

Imports System.Threading

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Dim t As Thread = New Thread(AddressOf Download)
t.Start()
Label1.Text = "Download Started"
End Sub

Private Sub Download()
' Do the download part here
End Sub

I hope this helps

Crouchie1998
BA (HONS) MCP MCSE
Nov 21 '05 #2

P: n/a
Hi !
The download part of the code makes the application appears like stop
responding.
My question is how to refresh the windows form right after changing the
label text.


You can either call Application.DoEvents() right after you change the
Label.Text property or make the download part in an other thread which
should make the download completely invisible to the user (the app won't
freeze or something).

--
Best Regards
Yanick
Nov 21 '05 #3

P: n/a
"Crouchie1998" <cr**********@spamcop.net> schrieb:
I am not sure if I really understand your post, but if you click a button
to
download something & then try to update a label. Am I right? If so, run
your
download from a new thread & then update your label text


In addition to your reply:

Note that some download methods in the .NET Framework provide support for
asynchronous operation. Otherwise, as you say, a worker thread is the way
to go. However, it's not allowed to access Windows Forms controls from
within the thread, so if you want to access the UI from within the thread,
you'll have to use interop techniques:

Multithreading in Windows Forms applications
<URL:http://dotnet.mvps.org/dotnet/faqs/?id=multithreading&lang=en>

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Nov 21 '05 #4

P: n/a
Thanks to all of you,
Your reply helped me.
Smith

"Zoury" <yanick_lefebvre at hotmail dot com> wrote in message
news:Oc**************@TK2MSFTNGP09.phx.gbl...
Hi !
The download part of the code makes the application appears like stop
responding.
My question is how to refresh the windows form right after changing the
label text.


You can either call Application.DoEvents() right after you change the
Label.Text property or make the download part in an other thread which
should make the download completely invisible to the user (the app won't
freeze or something).

--
Best Regards
Yanick

Nov 21 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.