473,396 Members | 2,158 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Threading and Listview optimization questions

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
2 1227
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: newbie | last post by:
Hello, I maybe asking too much in a single posting, but here it goes: I building a windows form that mimic's the Outlook XP GUI. Its a three pane form that will allow a user to view and edit...
6
by: Dan | last post by:
I've created a pocketpc app which has a startup form containing a listview. The form creates an object which in turn creates a System.Threading.Timer. It keeps track of the Timer state using a...
13
by: RCS | last post by:
I have a UI that needs a couple of threads to do some significant processing on a couple of different forms - and while it's at it, update the UI (set textboxes, fill in listviews). I created a...
2
by: Marten Van Keer | last post by:
Hi; I have two applications A and B *** Application B listens on a network stream with a callback function:
3
by: Michael.Suarez | last post by:
Is it me, or does it seem like they put no effort into creating the listview control in .Net. listview. A few gripes I have with .Net listview that aren't present in vb6: -Inability to set...
12
by: garyusenet | last post by:
I have had no replies to my previous post so perhaps I didn't write it good enough. Please excuse new thread but i wanted to break from the last thread hopefully this thread will be better. ...
2
by: cpix | last post by:
hi! i've been reading alot about the backgroundworker, but most of the articals only shows that you can use the progress-event to send a message to the form. Im trying to pass a listview with a...
2
by: John Rogers | last post by:
I have some code that does a recursive copy of whatever folder I give to it to copy the structure where I want it. I have it running in a single thread to make it a bit more efficient. So far it...
126
by: Dann Corbit | last post by:
Rather than create a new way of doing things: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2497.html why not just pick up ACE into the existing standard:...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.