I have a complex invoice form that has about 50 textfields on the form. It takes about 500 msec to grab the data from a remote database and about 500 msec to fill out the data on the form.
I built a scrollable window that places multiple invoices (as containers) on the window. I have a progress bar that shows progress while loading the data into properties on each container (via a thread so the progress bar would update). Once all the data is loaded, a method for each container is triggered to place the data from each property into each textfield.
This isn’t bad when showing a handful of invoices, but if you are displaying about 30 invoices, once all the data is grabbed (about 20 seconds) it still takes about 25 seconds to fill out all the forms. I guess it wouldn’t be too bad if I could show some sort of progress during the second half of this process, but the progress bar only works during the data grab.
I suspect part of this slowdown is having multiple containers loading at the same time. It appears that loading 20 containers is slower than loading 5 containers four times.
I have tried this with the window hidden or visible. It appears the load time is the same.
Any ideas on how this might be optimized?
(using Xojo 2013 r3.3)
Fire up Instruments if you are on the Mac and use the Time Profiler. If you are not on the Mac use the built in profiler.
Why can’t you use a progress bar for the second half of the proces???
It seems that when the window is being updated, the progress window is frozen also. The progress window only updates when the work is being done within a thread.
Then do your stuff in a thread. Should be done this way anyways. Yes, I know this is going to be painful.
Every Form does it own select on the db? You should use one select and then fill the form with these local data…
[quote=310967:@Marius Dieter Noetzel]Every Form does it own select on the db? You should use one select and then fill the form with these local data…
That’s true. I did think of that. That would speed up the initial phase of grabbing the data. Unfortunately, it still leaves me with the problem of how long the data takes to fill in the container.
I could load all the data into an array or hidden listbox and have the container pull the data from that.
Is it web?
You should use some system.DebugLog(date(new date).LongTime) in your code to see, where you are burning all this time.
Filling your forms should not need much time…
No. It’s a desktop app.
I did find a small time drain which cuts out the load time on 30 forms from 20 seconds to 17 seconds - but this is still a significant amount of time to fill out textfields from properties associated with the container.
Loading all the data in one sql statement will be quite fun since the data is coming from 6 tables.
Setting some textfields could not need so much time…
I just tried setting 100 Textfiedls with some text.
It needs 1145 Microseconds (0,001145 Seconds)
So there is something else, you are doing…
Could you send me example Project?
Also make sure no heavy calculations run when you set one field. Maybe add a flag where you ignore change events in controls while loading.
Found some code that might be the culprit. Thanks.
I didn’t realize it but there was a database query within the loading method. Moved it to the thread and it cut the load time down 60 to 70%.