Solved

Asynchronous File Search in .Net with Responsive listview

Posted on 2010-09-10
5
464 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
Internet Business Fax to Email Made Easy - With  eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, f…

911 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now