VB,Net, fast updating on textbox

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
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

AndyAinscowFreelance programmer / ConsultantCommented:
This might need a little modification but you can add the DoEvents which tells the application to perform any pending GUI work before continuing.

While SelectedFilesQueue.Count <> 0
            TextBox1.AppendText(SelectedFilesQueue.Dequeue.ToString & vbCrLf)
        End While

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
AndyAinscowFreelance programmer / ConsultantCommented:
In VB apparently it need the brackets
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.