473,719 Members | 2,892 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Performance issue (bug?) with .NET 2 ListView

Are there any know bugs with the ListView in .NET 2? I'm having
problems with an application that takes 15 seconds in 1.1, and now
takes over a minute. The code in question uses:

listViewItem = this.listView1. Items.Add(...)

followed by 7 calls to

listViewItem.Su bItems.Add(...)

When I comment out this code, the application runs in the same time as
the 1.1 version.

Any suggestions? I can provide the source code if required.

May 31 '06 #1
18 1956
I would suggest a: using the ListViewItem ctor that allows you to specify
the sub-items in one go, and b: using the {Begin|End}Upda te syntax (around a
block of such) - i.e.

listview.BeginU pdate();
try {
ListViewItem newItem = new ListViewItem(ne w string[] {
"text1","text2" ,"text3","text4 "});
listview.Items. Add(newItem);
// and again...
// and again...
// and again...
// (or use AddRange)
} finally {
listview.EndUpd ate();
}

See if that works any quicker... you could also try {Suspend|Resume }Layout.

Marc
May 31 '06 #2
What's happening in .Add(...)?
Please post a complete sample that illustraties the issue, without seeing
any code it's hard to tell what's happening.

Willy.

<mr*********@go oglemail.com> wrote in message
news:11******** **************@ c74g2000cwc.goo glegroups.com.. .
| Are there any know bugs with the ListView in .NET 2? I'm having
| problems with an application that takes 15 seconds in 1.1, and now
| takes over a minute. The code in question uses:
|
| listViewItem = this.listView1. Items.Add(...)
|
| followed by 7 calls to
|
| listViewItem.Su bItems.Add(...)
|
| When I comment out this code, the application runs in the same time as
| the 1.1 version.
|
| Any suggestions? I can provide the source code if required.
|
May 31 '06 #3
try to add the subitems *before* you add the item to the istview

--
<mr*********@go oglemail.com> schrieb im Newsbeitrag
news:11******** **************@ c74g2000cwc.goo glegroups.com.. .
Are there any know bugs with the ListView in .NET 2? I'm having
problems with an application that takes 15 seconds in 1.1, and now
takes over a minute. The code in question uses:

listViewItem = this.listView1. Items.Add(...)

followed by 7 calls to

listViewItem.Su bItems.Add(...)

When I comment out this code, the application runs in the same time as
the 1.1 version.

Any suggestions? I can provide the source code if required.

May 31 '06 #4
It's over 6000 items I'm adding, here's a snippet:

ListViewItem listViewItem =
this.listView1. Items.Add(e.Req uestInfo.IP);
listViewItem.Su bItems.Add(e.Re questInfo.DateA ndTime.ToString ("U"));
listViewItem.Su bItems.Add(e.Re questInfo.TimeD ifference+ "");
listViewItem.Su bItems.Add(e.Re questInfo.Reque st);
listViewItem.Su bItems.Add(e.Re questInfo.Statu s+" ");
listViewItem.Su bItems.Add(e.Re questInfo.Bytes + "");
listViewItem.Su bItems.Add(e.Re questInfo.Refer er);
listViewItem.Su bItems.Add(e.Re questInfo.Brows er);

which is taken from a small project I'm writing, full source is at:

http://www.gotdotnet.com/Workspaces/...1-dbe878a161b7

May 31 '06 #5
I also tried changing

// ListViewItem listViewItem =
this.listView1. Items.Add(e.Req uestInfo.IP);
ListViewItem listViewItem = new ListViewItem(e. RequestInfo.IP) ;
this.listView1. Items.Add(listV iewItem);

and also used BeginUpdate,End Update but with no improvement

May 31 '06 #6
Items.AddRange( ) will be your friend.

If you use .NET2.0 the VirtualMode of the listview class could also be a
great idea.

--
<mr*********@go oglemail.com> schrieb im Newsbeitrag
news:11******** *************@j 55g2000cwa.goog legroups.com...
It's over 6000 items I'm adding, here's a snippet:

ListViewItem listViewItem =
this.listView1. Items.Add(e.Req uestInfo.IP);
listViewItem.Su bItems.Add(e.Re questInfo.DateA ndTime.ToString ("U"));
listViewItem.Su bItems.Add(e.Re questInfo.TimeD ifference+ "");
listViewItem.Su bItems.Add(e.Re questInfo.Reque st);
listViewItem.Su bItems.Add(e.Re questInfo.Statu s+" ");
listViewItem.Su bItems.Add(e.Re questInfo.Bytes + "");
listViewItem.Su bItems.Add(e.Re questInfo.Refer er);
listViewItem.Su bItems.Add(e.Re questInfo.Brows er);

which is taken from a small project I'm writing, full source is at:

http://www.gotdotnet.com/Workspaces/...1-dbe878a161b7

May 31 '06 #7
I should've posted the whole method, here it is:

private void OnLineMatched(o bject sender,LogReade rLineEventArgs e)
{
if ( this.InvokeRequ ired )
{
OnLineMatchedDe legate d1 = new
OnLineMatchedDe legate(OnLineMa tched);
this.Invoke(d1, new object[] { sender, e });
}
else
{
// ListViewItem listViewItem =
this.listView1. Items.Add(e.Req uestInfo.IP);
ListViewItem listViewItem = new ListViewItem(e. RequestInfo.IP) ;
listViewItem.Su bItems.Add(e.Re questInfo.DateA ndTime.ToString ("U"));
listViewItem.Su bItems.Add(e.Re questInfo.TimeD ifference + "");
listViewItem.Su bItems.Add(e.Re questInfo.Reque st);
listViewItem.Su bItems.Add(e.Re questInfo.Statu s + " ");
listViewItem.Su bItems.Add(e.Re questInfo.Bytes + "");
listViewItem.Su bItems.Add(e.Re questInfo.Refer er);
listViewItem.Su bItems.Add(e.Re questInfo.Brows er);
this.listView1. Items.Add(listV iewItem);
this.listView1. EndUpdate();

this.statusBar1 .Panels[1].Text = e.CurrentLine + "/" +
e.TotalLines;
this.progressBa r1.PerformStep( );
}
}

public class LogReaderLineEv entArgs : EventArgs
{
...
public ServerRequestIn fo RequestInfo
{
get
{
return this.serverRequ estDetails;
}
}
}

public struct ServerRequestIn fo
{
public DateTime DateAndTime;
public string IP;
public string Request;
public int Status;
public string Browser;
public string Referer;
public string Method;
public int TimeDifference;
public int Bytes;
}

May 31 '06 #8
The fact it's working in 15 seconds in 1.1 and 1 minute in .NET 2 seems
to point to something else I feel

cody wrote:
Items.AddRange( ) will be your friend.

If you use .NET2.0 the VirtualMode of the listview class could also be a
great idea.

--
<mr*********@go oglemail.com> schrieb im Newsbeitrag
news:11******** *************@j 55g2000cwa.goog legroups.com...
It's over 6000 items I'm adding, here's a snippet:

ListViewItem listViewItem =
this.listView1. Items.Add(e.Req uestInfo.IP);
listViewItem.Su bItems.Add(e.Re questInfo.DateA ndTime.ToString ("U"));
listViewItem.Su bItems.Add(e.Re questInfo.TimeD ifference+ "");
listViewItem.Su bItems.Add(e.Re questInfo.Reque st);
listViewItem.Su bItems.Add(e.Re questInfo.Statu s+" ");
listViewItem.Su bItems.Add(e.Re questInfo.Bytes + "");
listViewItem.Su bItems.Add(e.Re questInfo.Refer er);
listViewItem.Su bItems.Add(e.Re questInfo.Brows er);

which is taken from a small project I'm writing, full source is at:

http://www.gotdotnet.com/Workspaces/...1-dbe878a161b7


May 31 '06 #9
Just a thought:

Do you have any try catches that might be swallowing an exception?
Perhaps an exception is being generated and swallowed.

May 31 '06 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
5223
by: Paul Mateer | last post by:
Hi, I have been running some queries against a table in a my database and have noted an odd (at least it seems odd to me) performance issue. The table has approximately 5 million rows and includes the following columns: DocID (INTEGER, PRIMARY KEY, CLUSTERED) IsRecord (INTEGER, NONCLUSTERED)
0
1256
by: Mortisus | last post by:
Hi, I'm running a fulltext query on a ~50000 record mysql database and while performance is usually satisfying - about 0.02 secs per query, i get a critical performance deterioration when looking for popular keywords (words that appear in more than 50% of the data) - about 0.25 secs/query. I know that the standard fulltext engine does not return any results on such words, and this is good, but this does not explain the performance issue....
1
1355
by: bob | last post by:
Currently i'm writing some low level communication modules in C++ and is thinking of putting it into a library so that it can be used in C#. My concern is the performance issue when putting C++ codes into C#. Does anyone has any idea(s) on this issue????
17
2059
by: 57R4N63R | last post by:
I'm currently building a website for one of the client. There has been few errors here and there, but just recently the problem is getting worse. Basically the symptoms is that when the user try to access the page, it takes really long time to load. However, after up to 1 hour, the website will run fine again as normal. This issue has been there with the site. I usually just ask the system admin to restart the IIS Service. However, the...
4
2237
by: Ira Siyal | last post by:
Hi I had a project in VB6 which I upgraded to VB.NET recently. In the app, I am facing some issue with listview control. In the earlier app, I have set the Icons in listview through an imagelist. but i notice that while i execute the project in .net, the step that sets the icon prop. throws an exception.
5
2028
by: Varangian | last post by:
Hi, I have a performance issue question? which is best (in terms of efficiency and performance, I don't care neatness in code)... building an ArrayList of Object Instances using SqlDataReader OR using SqlDataAdapter to Fill a DataSet or DataTable ? Thanks!
0
1481
by: Shades799 | last post by:
Hi All, I was wondering if any of you could help me with a very difficult problem that I am having. I have an ASP site that works with an Oracle database using an ADODB connection. This connection is stored in a .dll file. This site had been working fine. However recently we upgraded our Oracle database from 9i to 10g and ever since then we have been having serious performance problems with this site only. The website works fine...
0
8727
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9365
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9055
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7998
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5972
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4482
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4748
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2567
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2125
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.