Link to home
Start Free TrialLog in
Avatar of ITPOL
ITPOLFlag for United Kingdom of Great Britain and Northern Ireland

asked on

Asynchronous File Search in .Net with Responsive listview

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
Avatar of existenz2
existenz2
Flag of Netherlands image

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.
Avatar of ITPOL

ASKER

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...
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.
ASKER CERTIFIED SOLUTION
Avatar of Snarf0001
Snarf0001
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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)