I am trying to implement a log viewer in c#. It has to read from a static text file and make it a bit more readable. Because I am new to windows forms and c#, the listview looked like the easiest way of implementing the functionality I needed (background highlighting, doubleclick on a row). Unfortunately when I moved from my 100 line test text file to a more realistic 20mb text file my program slowed to a crawl (about 1 minute before it showed any text).

here is the code I used to add the listviewItems

String line;         
while((line = fileRead.ReadLine())!= null)
    ListViewItem lvi = new ListViewItem();
    lvi.Text = line;


If anyone has any suggestions on how I could speed this up I would greatly appreciate it but I think I will probably have to move onto a different type of container. I have had a look at the dataGridView but that looks like a bit of overkill for parsing a text file. Does anyone have any recommendations?

Multithreading if you need to go on your way.

yep threading could be the answer but it doesn`t seem to be the listviewItems that are causing the trouble. The crunch seems to happen when the listview is updated and as there is only one listview object, I dont see how I could thread it. Again i`m very new to this so I apologise if I have missed your point, thanks for the help!

I understood you, in such cases we used another thread to smooth the way in updating controls.

I tried messing around with a threaded update and it did make it update more smoothly but the problem is that some of the log files that I may be working on are ~100 mb and at this point it looks like it could take 5 minutes to completely add them all to the window! do you have any other suggestions for a container that could handle this more quickly? Thanks again for your help!

Sure that's out of your hand!!! you can't speed up the operation it completely depends on your machine processor(s).