By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,534 Members | 943 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,534 IT Pros & Developers. It's quick & easy.

Threading and Listview optimization questions

P: n/a
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!
Nov 21 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
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

--
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
Nov 21 '05 #2

P: n/a
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

"Mattias Sjögren" <ma********************@mvps.org> wrote in message
news:uw**************@TK2MSFTNGP10.phx.gbl...
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

--
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.

Nov 21 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.