0

Hey!
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

logView1.BeginUpdate();
String line;         
while((line = fileRead.ReadLine())!= null)
{
    ListViewItem lvi = new ListViewItem();
    lvi.Text = line;
    logView1.Items.Add(lvi);                  
}
                     
fileRead.Close();
fileNew.Close();

logView1.EndUpdate();

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?
regards
Jonathan

2
Contributors
5
Replies
6
Views
8 Years
Discussion Span
Last Post by Ramy Mahrous
0

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!

0

Hi,
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!

0

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

This article has been dead for over six months. Start a new discussion instead.
Take the time to help us to help you. Please be thoughtful and detailed and be sure to adhere to our posting rules.