Threading and Listview optimization questions

  • Thread starter Thread starter André Nogueira
  • Start date Start date
A

André Nogueira

Hi there.
I am developing an explorer-like application.
However, there is one problem.
If the current dir has many files, it will take a while to populate the
listview with all the files and folders.
How can I overcome this? Programs such as Total Commander have no problem
what so ever. So is there anything I can do?
Also, how can I populate both the treeview and the listview from a new
thread?
I have already tried

Private Sub TreeView1_AfterSelect(ByVal sender As System.Object, ByVal e As
System.Windows.Forms.TreeViewEventArgs) Handles TreeView1.AfterSelect
TN = e.Node
Dim T As New Threading.Thread(AddressOf ThUpd)
T.Start()
End Sub

Sub ThUpd()
Dim mi As New MethodInvoker(AddressOf Me.UpdateViews)
Me.BeginInvoke(mi)
End Sub

But that makes the program run as if no new thread was created and still
blocks the user from using the program's UI.

Thank you!
 
André,
Sub ThUpd()
Dim mi As New MethodInvoker(AddressOf Me.UpdateViews)
Me.BeginInvoke(mi)
End Sub

But that makes the program run as if no new thread was created and still
blocks the user from using the program's UI.

I assume most of your work is done in the UpdateViews method, which
still executes on the UI thread. You have to move the time consuming
task to execute on the background thread, and then only use the UI
thread for inserting the new item in the control.



Mattias
 
And how do I do that? My problem is adding items to the listview and the
treeview from a thread...
I need to add nodes to the "e" object passed on to the TreeView1_AfterSelect
sub.

André Nogueira
 
Back
Top