Vb.net application - progress update screen

  • Thread starter Thread starter tedqn
  • Start date Start date
T

tedqn

I have simple vb application that loops through a list of filename and
perform a System.IO.File.Copy from one server to another. I have a
readonly textbox where I append messages showing what's going on. ie.

Processing ..
Copy \\Server1\file1 to \\Server2\file1 ... Done
Copy \\Server1\file2 to \\Server2\file2 ...

The copy process is slow for each file copy and the TextBox doesn't
show the messages until the whole program finished running. Is there a
way to make the TextBox render the partial result for each copying?
 
In your loop that is copying files, try calling the Refresh method of the
TextBox.

TextBox.AppendText("Processing .." & vbcrlf)

For Each oFile as File in MyListOfFiles

TextBox.AppendText("I'm coping stuff ... ")
TextBox.Refresh

oFile.Copy ...

TextBox.AppendText("Done" & vbcrlf)

Next

Or move your file copying to a seperate thread.
 
I have simple vb application that loops through a list of filename and
perform a System.IO.File.Copy from one server to another. I have a
readonly textbox where I append messages showing what's going on. ie.

Processing ..
Copy \\Server1\file1 to \\Server2\file1 ... Done
Copy \\Server1\file2 to \\Server2\file2 ...

The copy process is slow for each file copy and the TextBox doesn't
show the messages until the whole program finished running. Is there a
way to make the TextBox render the partial result for each copying?

To ensure that screen updates are reflected as soon as possible, put
an:

Application.DoEvents

inside the copy loop.
 
Great. Application.DoEvents did just fine. I haven't tried the
TextBox.Refresh method but thanks too.
 
Back
Top