Solved

Asynchronous File Search in .Net with Responsive listview

Posted on 2010-09-10
5
468 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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 23

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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…

630 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