Link to home
Start Free TrialLog in
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
ASKER CERTIFIED SOLUTION
Avatar of AndyAinscow
AndyAinscow
Flag of Switzerland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
In VB apparently it need the brackets
Application.DoEvents()