Solved

Asynchronous File Search in .Net with Responsive listview

Posted on 2010-09-10
5
463 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

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…
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…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

771 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

12 Experts available now in Live!

Get 1:1 Help Now