By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,571 Members | 1,837 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,571 IT Pros & Developers. It's quick & easy.

Listview

P: n/a
Ken
I have a listview with 24 rows and 150 columns. I update 3 rows every 10
seconds.

1 2 3 4 ... 150
row1
row2
row3
row4
..
..
..
row24

When this update occurs, I get a processor "spike" of 100% for a total of 7
seconds each update. This "spike" appears to use all of the processor which
is having adverse effects on other threads in the application (losing data,
failed communications, etc..).

I wrote example listviews in Visual C++ 6, Visual Basic 6, and VB .NET. Each
listview performed the same task - update 3 rows every ten seconds.

C++ and VB 6: There was a very small bump in processor usage - around 10% -
12%.
VB .NET: There was a spike of 60% - 70%.

It appears that updating a listview - in VB .NET - can be very expensive.

Has anyone else noticed this problem?
Is there a way to present the data this way without causing the processor
"spike" in VB .NET?
Why is there such a big difference between C++6,VB6, and VB .NET?

Thanks for your help.

K


Nov 21 '05 #1
Share this Question
Share on Google+
6 Replies


P: n/a
Have you tried turning off the painting until all three rows are
updated?

listviewName.BeginUpdate()
Do your updating here
listviewName.EndUpdate()

Shane

Nov 21 '05 #2

P: n/a
Ken,

Can you tell us how long processing of this code takes.

Just a new project a listview on it and than this in the loadevent

\\\
ListView1.View = View.Details
For i As Integer = 1 To 150
ListView1.Columns.Add(i.ToString, 40, HorizontalAlignment.Left)
Next
Dim start As Integer = Environment.TickCount
ListView1.BeginUpdate()
For j As Integer = 1 To 24
ListView1.Items.Add(j.ToString)
For i As Integer = 1 To 150
ListView1.Items(j - 1).SubItems.Add(i.ToString)
Next
Next
ListView1.EndUpdate()
MessageBox.Show((Environment.TickCount - start).ToString & "Ms")
///

I hope this helps,

Cor
Nov 21 '05 #3

P: n/a
Ken
Thanks.

Yes, I tried it and it gives a wicked flicker of the entire list control.
No (good) change in processor usage.

"Shane" <sh********@yahoo.com> wrote in message
news:11**********************@o13g2000cwo.googlegr oups.com...
Have you tried turning off the painting until all three rows are
updated?

listviewName.BeginUpdate()
Do your updating here
listviewName.EndUpdate()

Shane

Nov 21 '05 #4

P: n/a
Ken
Thanks. The test I conducted with the code below takes approx 120
milliseconds.

I have added something to the code that makes it more or less a mirror of
what I am doing. It is listed below. It takes much more time. Any major
problems with it that you can see?

Added a timer and set the interval to 10000 ms.
Inside the timer method:

Dim start As Integer = Environment.TickCount
ListView1.BeginUpdate()
For j As Integer = 1 To 24
For i As Integer = 1 To 150
ListView1.Items(j - 1).SubItems(i).Text = i.ToString
Next
Next
ListView1.EndUpdate()
MessageBox.Show((Environment.TickCount - start).ToString & "Ms")
I also changed your code snippet to add all 0's upon startup. This is how my
app currently functions.


"Cor Ligthert [MVP]" <no************@planet.nl> wrote in message
news:%2******************@TK2MSFTNGP09.phx.gbl... Ken,

Can you tell us how long processing of this code takes.

Just a new project a listview on it and than this in the loadevent

\\\
ListView1.View = View.Details
For i As Integer = 1 To 150
ListView1.Columns.Add(i.ToString, 40, HorizontalAlignment.Left)
Next
Dim start As Integer = Environment.TickCount
ListView1.BeginUpdate()
For j As Integer = 1 To 24
ListView1.Items.Add(j.ToString)
For i As Integer = 1 To 150
ListView1.Items(j - 1).SubItems.Add(i.ToString)
Next
Next
ListView1.EndUpdate()
MessageBox.Show((Environment.TickCount - start).ToString & "Ms")
///

I hope this helps,

Cor

Nov 21 '05 #5

P: n/a
Ken
I have been testing your scenario some more. I have come up with a 70-80
millisecond time when loading. Just a FYI. 120 to 80 Ms is a big difference.

"Cor Ligthert [MVP]" <no************@planet.nl> wrote in message
news:%2******************@TK2MSFTNGP09.phx.gbl...
Ken,

Can you tell us how long processing of this code takes.

Just a new project a listview on it and than this in the loadevent

\\\
ListView1.View = View.Details
For i As Integer = 1 To 150
ListView1.Columns.Add(i.ToString, 40, HorizontalAlignment.Left)
Next
Dim start As Integer = Environment.TickCount
ListView1.BeginUpdate()
For j As Integer = 1 To 24
ListView1.Items.Add(j.ToString)
For i As Integer = 1 To 150
ListView1.Items(j - 1).SubItems.Add(i.ToString)
Next
Next
ListView1.EndUpdate()
MessageBox.Show((Environment.TickCount - start).ToString & "Ms")
///

I hope this helps,

Cor

Nov 21 '05 #6

P: n/a
Just curious,
Are you doing this as a client app or as a web app with a server side
control?
"Ken" <ks***@s32443t.com> wrote in message
news:uD****************@TK2MSFTNGP10.phx.gbl...
I have a listview with 24 rows and 150 columns. I update 3 rows every 10
seconds.

1 2 3 4 ... 150
row1
row2
row3
row4
.
.
.
row24

When this update occurs, I get a processor "spike" of 100% for a total of 7 seconds each update. This "spike" appears to use all of the processor which is having adverse effects on other threads in the application (losing data, failed communications, etc..).

I wrote example listviews in Visual C++ 6, Visual Basic 6, and VB .NET. Each listview performed the same task - update 3 rows every ten seconds.

C++ and VB 6: There was a very small bump in processor usage - around 10% - 12%.
VB .NET: There was a spike of 60% - 70%.

It appears that updating a listview - in VB .NET - can be very expensive.

Has anyone else noticed this problem?
Is there a way to present the data this way without causing the processor
"spike" in VB .NET?
Why is there such a big difference between C++6,VB6, and VB .NET?

Thanks for your help.

K

Nov 21 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.