Label.Text refresh .... ?

  • Thread starter Thread starter Allen Smith
  • Start date Start date
A

Allen Smith

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
 
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
 
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).
 
Crouchie1998 said:
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>
 

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

Back
Top