Controls updating painfully slow

I have a rather simple application that saves image data to a sqlite database.

I have a series of popup menus, radio buttons & check boxes that allow the user to set options for the image to the database.

I have a list box that shows the data from 5 fields in the db.

When I click from line to line in the list box, it takes ~7 seconds for the associated controls to display the proper values.

The database has a field: “requirements”
When the list box loads the items from the record set, and you click, on say the first entry, The code takes the value that is in “requirements” and then set the proper true/false value for the check box in the user interface:

Here is the code, which I have expanded a bit for clarity:
// grab the data from the recordset (rs)
command = rs.Field(“requirements”).StringValue
//for clarity, I stepped this out as there are three possible values that can be in the requirement field, all separated by a space, I am looking
for the first value, so I use NthField:
myvalue = NthField(command," ",1)
//Now I check to see if it is the value I am looking for, and then I set the control to look proper for the user:
if myvalue = “Proof-Required” then
window1.CheckBox1.value = true
else
window1.CheckBox1.value = false
end if

According to the Profiler, this event is taking an average of 1865 milliseconds. I have 17 user interface controls that require possible updating, depending on what the database values are.

I created a method to handle just the updates to the UI, then pass the recordset to the method: UpdateControls(rs) which is called when the listbox containing my dataset is changed. Profiler shows the UpdateControls method requiring an average of 7300 milliseconds to complete.

Here is another odd issue: I am putting the image that I am processing through the PictureToString & StringToPicture functions (per the Language reference) to store the image to the database. That process only takes about ~400 milliseconds.

So it is taking around 7 seconds to update controls, but less than 1/2 second to process an 8 meg image to a string & then write that string info to the database!

Any help would be terrific

-Patrick

Should not take that long… but you can condense it to ONE Line

window1.checkbox1.value=(instr(rs.field("requirements").stringvalue,"Proof-Required")>0)

other that that… are you sure the large amount of time is not due to the database itself? The rest of it should be so fast as to barely be detectable

Dave,

Funny, that is the line I used originally. I was not sure what was taking so long, so I expanded the line (per my message) so I had a break point to see what was happening.

I also broke up the function into two parts, the querying of the database, then I pass the database to the updateControls(rs) method.

The database takes maybe .1 sec to query & return results.

The profiler shows all the delay coming from updating controls, in the UpdateControls method.

This is a mystery

-Patrick

Without having some code to review its hard to surmise what might be causing this

Norman, what would you like to see? I can send you an excerpt if you would like.

-Patrick

File a feedback report & attach your project to it privately
We’ll treat this as under NDA and see whats up

I bet you have an update loop going on. For example, UpdateControls changes your Listbox, which triggers the Change event, which triggers another call to UpdateControls, etc.

Because these situations can be difficult to troubleshoot with a static breakpoint - they often only happen after a very specific series of user interactions - I use a conditional breakpoint triggered with a keyboard key:

If Keyboard.AsyncOptionKey then
break
End

Place that code at the beginning of your UpdateControls code and hold down the Option key while you trigger the update that is taking so long.

Eric,

You hit the nail on the head!!! Thanks for the insight!

Problem resolved.

-Patrick

Cool! I thought that was a shot in the dark - glad it was helpful.

As a solution, I have a flag named “ignoreChanges” that I set to true in routines like UpdateControls. In each control’s Change event (or whatever it is named), if ignoreChanges=true then it doesn’t respond to the event. The value gets set to false when UpdateControl exists.

Eric,

Again, that was exactly my fix! Twice you have shed light on my code deficiency!!

Again, thanks for the suggestions, they were both spot on. Norman, thank you for your attentiveness as well.

-Patrick