Avatar of PNRT
PNRT
 asked on

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
Visual Basic.NET.NET Programming

Avatar of undefined
Last Comment
AndyAinscow

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
AndyAinscow

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
AndyAinscow

In VB apparently it need the brackets
Application.DoEvents()
I started with Experts Exchange in 2004 and it's been a mainstay of my professional computing life since. It helped me launch a career as a programmer / Oracle data analyst
William Peck