Solved

Asynchronous File Search in .Net with Responsive listview

Posted on 2010-09-10
5
466 Views
Last Modified: 2012-05-10
Hi,

I have been building a simple file search utility, but a struggling to make it responsive enough.

I have got the async search working fine using a background worker, but the listview that holds the results ends up being unresponsive due to the number of items being added to it.  Ideally I would like it to function as the search does in Windows Explorer, in that you can happily click on any of the resuts whilst the listview is still being populated.

I am using the BW's progresschanged event to signal added a new item to the listview.  Its roughly based on this article;

http://msdn.microsoft.com/en-us/magazine/cc163828.aspx

Anyone have any thoughts?  perhaps I have come at this the wrong way...

thanks
0
Comment
Question by:ITPOL
5 Comments
 
LVL 14

Expert Comment

by:existenz2
ID: 33645482
I would cache the results and add them every 5 seconds for example. That would make it more responsive. I would also think about paging, so that not to many results will come in the view and that everything stays responsive.
0
 
LVL 1

Author Comment

by:ITPOL
ID: 33645661
Ah ok, at the moment I have a generic collection holding fileInformation objects.  Any suggestions on how i would go about paging them to the listview?

Thanks for your input, by the way...
0
 
LVL 14

Expert Comment

by:existenz2
ID: 33645734
With LINQ you can easily implement paging by default (Skip) and (Take) methods. In the UI just implement 2 buttons, next and previous. And a few labels to show current page and item count. By click on the buttons you get the latest set of data and bind that to the grid.
0
 
LVL 22

Accepted Solution

by:
Snarf0001 earned 500 total points
ID: 33646229
I think I would go a different route.  I much prefer adding the results as they are found, rather than polling every 5 seconds.
In addition, in a windows environment, users are not accustomed to seeing paging.

Have a look at the .VirtualMode on the listview, it's a bit more work to implement, but in the end enables you to have a listview with hundreds of thousands of items with little performance degredation.

http://www.codeproject.com/KB/list/VirtualModeListView.aspx
0
 
LVL 5

Expert Comment

by:samml
ID: 33652619
And I think snarf's solution will solve your thread problem. You can store your items in a global variable which can be accessed from everywhere. Now you can set VirtualListSize in the DoWork-event, if you want to: Me.Invoke(Sub() ListView1.VirtualListSize = 123)
0

Featured Post

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…

821 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question