We help IT Professionals succeed at work.
Get Started

VB,Net, fast updating on textbox

PNRT asked
Last Modified: 2015-06-08
Hi Experts
VB.Net 4
I have a queue to which I am adding +- 5000 strings on a separate thread
To Speed things up, while these strings are being added, I am taking the strings from the queue and adding them to a textbox, fired from a timer on the main thread.

If I use -
        If SelectedFilesQueue.Count <> 0 Then
            TextBox1.AppendText(SelectedFilesQueue.Dequeue.ToString & vbCrLf)
        End if
It works well but is VERY slow to complete

If I use -
          While SelectedFilesQueue.Count <> 0
            TextBox1.AppendText(SelectedFilesQueue.Dequeue.ToString & vbCrLf)
        End While
This is fast, takes a quarter of the time, but it freezes my GUI.

If I try and add the second example to a separate thread,  I still have the problem of updating the GUI from that thread
Anyone know how to keep the speed but stop the GUI from freezing?
Thanks in advance
Watch Question
Freelance programmer / Consultant
This problem has been solved!
Unlock 1 Answer and 2 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE