NBrus

Hi,

I have recently moved to using Visual Studio 2005 for all future development work and so I upgraded an existing Visual Studio 2003 Windows Forms Application to use .NET 2.0. There were a few things I had to fix after the upgrade wizard completed (with no errors), but mostly relating to initialising declared variables etc, nothing drastic.

However, I fully expected my application to run at least at the same speed as before if not a little faster, but was shocked to discover that EVERYTHING now runs about 1/10th the speed of the .NET 1.1 version. This includes major slowdown when populating listviews and accessing data using ado etc.

Is this normal

I have no errors and my new app is slow even though the exact same code is running when populating my listview, or accessing data via ADO. I am at a loss and have spend countless hours searching the web to find others with this issue, but have come up empty handed.

Can anyone please shed some light on this

I don't wish to go back to working with .NET 1.1 (VS2003), but if this performance loss is normal, I'll have no choice.



Re: Windows Forms General VB.NET Windows Forms App VERY SLOW after upgrading from .NET 1.1 (VS2003) to .NET 2.0 (VS2005)

Ðãv? S. Â???????

Franlky, its hard to say. It could be poor use of the framework on your part, or something in your code bogging your application down. The only way to find out is to extensively debug your program, improve your programs logical algorithims and etcetera. Lets start with you elaborating a bit on what your program is/does






Re: Windows Forms General VB.NET Windows Forms App VERY SLOW after upgrading from .NET 1.1 (VS2003) to .NET 2.0 (VS2005)

NBrus

Hi,

Thanks for responding to my post ...

My program is a schedule planner application that uses a ListView control to display/edit timelines representing a 24 hr day (one day is displayed at a time). A second single item listview is used to edit a selected item by 'painting' timelines using a mouse. The user can select the type of 'time' element they wish to paint (e.g. basic hours, overtime, sick, authorised absence, etc.) and the subitems are filled-in as they 'paint' over the subitems. This is probably a non-standard way of using a listview, but it works nicely. In .NET 1.1 I used an API call to get the subitem location to paint, but now I have switched to using the built-in GetSubItemAt function of the new listview control in .NET 2.0 (the old API method still works though, but is no faster). I also manually code all my dataAdapters and sql statements.

Essentially, I have each listview item as an employee id with subitems consisting of employee name followed by a 24 hr day represented by 96 subitems of 15 minutes each. These 'time' subitems are populated by a single character as stored in a database and the subitem cell is coloured (backcolor/forecolor) according to the character in each subitem. The display shows a color-coded graphical view of each listed employee's daily work pattern. I also perform data validation on each listview item and highlight the employee id item for employees that are incorrectly set up on the system.

If there was some way I could upload an image I would (maybe someone can help), it might help in explaining this.

The problem I have is that the ADO code that loads the access database into a dataset works as before, and my listview populate function works as before. There is nothing I can see that is wrong with these (I can post some code later if you wish). What I cannot understand is why the exact same code (listview populate, data access and data validation) now runs at 1/10th speed (compiled in Visual Studio 2005) that it did when the application was compiled with Visual Studio 2003. I do not get any errors and my application works correctly as before, only at a snail's pace!

Maybe the upgrade wizard did something that I am unaware of

This issue remains regardless of what PC I run my app on. I am completely baffled ... Do I need to rewrite everything from scratch






Re: Windows Forms General VB.NET Windows Forms App VERY SLOW after upgrading from .NET 1.1 (VS2003) to .NET 2.0 (VS2005)

Ðãv? S. Â???????

You can have your images hosted at an image hosting service such as ImageShack.

How exactly are you "drawing" this stuff






Re: Windows Forms General VB.NET Windows Forms App VERY SLOW after upgrading from .NET 1.1 (VS2003) to .NET 2.0 (VS2005)

NBrus

I used the ListView MouseMove event (together with left mouse button down test) to track the subitem location, and then I update the datarow and listview item as each subitem is updated with the appropriate character ('B' for basic hours, 'O' for overtime, etc.) and I set the corresponding subitem forecolor/backcolor. I change the width of the subitems to 'zoom' in/out, so normally the text in the subitem cell isn't visible, hence the use of colors. In .NET 2.0, even adding items to the listview is so much slower than before and that is a simple operation. Previously, populating the listview with 100 items and validating the data took less than 1 second ... now it is taking around 24 seconds!

*Edit: I go and do some more testing on the ADO side to see if that really is slower ... it is slower stepping through with the debugger (waiting for each step to be executed), but this isn't a valid test, so I'll need to re-examine this and post back here. The data validation does access the dataset and I've already timed this and it is way slower than before, so this does indicate slow ADO performance. I'm off to try and get an image uploaded ...

Here is a screen capture (with real names obscured) ...


http://img402.imageshack.us/img402/2405/timeline2ja8.jpg


Do you need me to post some code

Here is some now slow ADO code used to validate the entered schedules ...

Private Sub HighlightInvalidSchedules()

'check if the user is viewing/editing the standard hours
Dim bIsAutoFillTask As Boolean = optAutoFill.Checked

'check if the displayed schedule corresponds to the latest timeline import (this is where the contract hours come from)
Dim bIsLatestTimeline As Boolean = (GetRepID(dtpSchedule.Value) = GetMaxRepID()) And Not bIsAutoFillTask

'check if the user is viewing/editing forecast schedules
Dim bIsForecast As Boolean = (GetRepID(dtpSchedule.Value) = 0) And Not bIsAutoFillTask

'used to ensure that only AutoFill, current, or forecast schedules are highlighted
Dim bApplyHighlight As Boolean = bIsAutoFillTask Or bIsLatestTimeline Or bIsForecast

'highlight contract changes
If bApplyHighlight Then
'disable listview screen draw
lvwSchedule.BeginUpdate()
'iterate through the main listview items collection
For Each item As ListViewItem In lvwSchedule.Items
'compare the hours
Dim bHoursNotEqual As Boolean = (GetWeekAutoFillHours(item.Text) <> GetWeekContractHours(GetMaxRepID, item.Text))
'colour the items
If bHoursNotEqual Then
item.BackColor = Color.Red
item.ForeColor = Color.White
Else
item.BackColor = Color.White
item.ForeColor = Color.Black
End If
Next
're-enable listview screen re-draw
lvwSchedule.EndUpdate()
End If

End Sub

--

Public Shared Function GetWeekAutoFillHours(ByVal empID As String) As Double

Dim dvAutoFill As New DataView(frmTimeline.dsTimeline.Tables("Schedule"))

'sort the dataview ready for find
dvAutoFill.Sort = "dateID, empID"

Dim drvSunday As DataRowView = dvAutoFill(dvAutoFill.Find(New Object() {Constants.Sundays, empID}))
Dim drvMonday As DataRowView = dvAutoFill(dvAutoFill.Find(New Object() {Constants.Mondays, empID}))
Dim drvTuesday As DataRowView = dvAutoFill(dvAutoFill.Find(New Object() {Constants.Tuesdays, empID}))
Dim drvWednesday As DataRowView = dvAutoFill(dvAutoFill.Find(New Object() {Constants.Wednesdays, empID}))
Dim drvThursday As DataRowView = dvAutoFill(dvAutoFill.Find(New Object() {Constants.Thursdays, empID}))
Dim drvFriday As DataRowView = dvAutoFill(dvAutoFill.Find(New Object() {Constants.Fridays, empID}))
Dim drvSaturday As DataRowView = dvAutoFill(dvAutoFill.Find(New Object() {Constants.Saturdays, empID}))

'iterate through the columns of our row
Dim weekTotalHours As Double = 0
For iCol As Int32 = 5 To (dvAutoFill.Table.Columns.Count - 1)
'sum all basic hours allocated
If (drvSunday.Item(iCol).ToString = Forecast.Basic) Then
weekTotalHours += Constants.iTimeIntervalSize
End If
If (drvMonday.Item(iCol).ToString = Forecast.Basic) Then
weekTotalHours += Constants.iTimeIntervalSize
End If
If (drvTuesday.Item(iCol).ToString = Forecast.Basic) Then
weekTotalHours += Constants.iTimeIntervalSize
End If
If (drvWednesday.Item(iCol).ToString = Forecast.Basic) Then
weekTotalHours += Constants.iTimeIntervalSize
End If
If (drvThursday.Item(iCol).ToString = Forecast.Basic) Then
weekTotalHours += Constants.iTimeIntervalSize
End If
If (drvFriday.Item(iCol).ToString = Forecast.Basic) Then
weekTotalHours += Constants.iTimeIntervalSize
End If
If (drvSaturday.Item(iCol).ToString = Forecast.Basic) Then
weekTotalHours += Constants.iTimeIntervalSize
End If
Next

'return the week total
Return weekTotalHours

End Function

--

Public Shared Function GetWeekContractHours(ByVal repID As Int32, ByVal empID As String) As Double
Try
Dim weekTotalHours As Double = 0

'get the BasHours ref. values from employee table and calc the total for the week
Dim employee As DataRow = frmTimeline.dsTimeline.Tables("Employee").Rows.Find(New Object() {repID, empID})
If Not employee Is Nothing Then
'get the employee weekly std hours (total as defined in the employee table) for the selected employee
weekTotalHours = CDbl(employee("contractHoursSun")) _
+ CDbl(employee("contractHoursMon")) _
+ CDbl(employee("contractHoursTue")) _
+ CDbl(employee("contractHoursWed")) _
+ CDbl(employee("contractHoursThu")) _
+ CDbl(employee("contractHoursFri")) _
+ CDbl(employee("contractHoursSat"))
End If
'return the total
Return weekTotalHours

Catch ex As Exception
MsgBox("Error Message: " & vbNewLine & vbNewLine & ex.Message, MsgBoxStyle.Critical, "Error")
End Try
End Function





Re: Windows Forms General VB.NET Windows Forms App VERY SLOW after upgrading from .NET 1.1 (VS2003) to .NET 2.0 (VS2005)

Ðãv? S. Â???????

Your best bet at pin-pointing the low-performance code is trying to find where exactly the large delays occurr. From there, you can further diagnose the problem. Off hand, I don't personally see anything that could be of low-performance, although the Find() calls make me wonder because of the content of your ListView control.





Re: Windows Forms General VB.NET Windows Forms App VERY SLOW after upgrading from .NET 1.1 (VS2003) to .NET 2.0 (VS2005)

NBrus

I'll do some more testing and post back ... as mentioned already, this same code and all other code runs much, much, faster when it was running under .NET 1.1 ... the simple upgrade to .NET 2.0 seems to have resulted in major slowdown of everything ... something I find completely baffling. I have both versions of the application here and can run side by side and the performance between them is like night and day.

The example validation code I posted above runs each time the listview is populated and at less than one second on 100 ListItems is perfectly usable (.NET 1.1). Running identical code in the new upgraded (.NET 2.0) application takes around 24 seconds, which is completely unacceptable. I am using untyped datasets if that helps. I haven't posted the ListView populate routine, which is also suffering from major slowdown, but it feels to me that the whole application is in SLOWWWW... mode, not just one or two functions.

The largest delays are in the data validation routine I posted, and these are most noticable due to taking over 20 seconds to run. If I comment out the data validation, then the ListView populates in around 2.5 seconds (old version was less than 0.25 seconds).

None of this makes sense to ... same code ... different results ... I don't know what I can do. This is my first time posting on forums for help because I have no experience yet of using .NET Framework 2.0, so I wondered if this was normal behaviour after an upgrade.

Have I missed any settings in my development environment I have both VS2003 and VS2005 installed.

Ruling out .NET 2.0 as the cause for slowdown would be a useful step forward ...

PS: Thanks for taking the time to help Dave, it is much appreciated ...





Re: Windows Forms General VB.NET Windows Forms App VERY SLOW after upgrading from .NET 1.1 (VS2003) to .NET 2.0 (VS2005)

Ðãv? S. Â???????

I've helped as much as I can here, I wish I could help more, but my knowledge on the 1.1 framework is slim to none. Hopefully someone else may be able to throw in some useful information.





Re: Windows Forms General VB.NET Windows Forms App VERY SLOW after upgrading from .NET 1.1 (VS2003) to .NET 2.0 (VS2005)

NBrus

Sincerest thanks for all your input Dave ...

I have another new application to develop (in VS2005), so I am going to leave this one for now and come back to it later hopefully with some new ideas. As I said before, this problem has me completely baffled, and I don't want to waste any more time on it for now. I will post back here if/when I do get to the bottom of this at some point, but for now I don't know what else I can do. Thanks again, and also to all those that stopped by to read this thread ...