View previous topic :: View next topic |
Author |
Message |
AJ83 KiXforms Follower

Joined: 14 Jun 2007 Posts: 16
|
Posted: Tue Nov 13, 2007 4:38 pm Post subject: Excessive CPU usage |
|
|
Hi,
I built a pretty neat 6000 line program in kixforms.net to process information from a PDF (scanned mail) into an SQL database.
Some of the information has to be chosen from pre-filled comboboxes (Extracted from SQL databases at program start)
Some information entered is validated against SQL databases.
Some information has to be searched for(Query`s to sql databases, with results in listview)
Today i noticed that the program constantly uses 1,5Ghz of CPU. Which is quite strange since it isn`t doing things all the time.
My first hunch is that it might be something to do with the sql communication, but everytime i use sql comminication, i open a connection, query, and close the connection.
But if this was the problem, you would expect the cpu usage to rise after using some more sql based functions, but this isn`t the case. The usage stays on a steady 50% on my 3Ghz machine.
What can be the cause of such behaviour? Can constant refresh of the interface be the culprit? The interface is quite complicated, it is 1024x768 Full screen, wich can slide to reveal another large portion of interface, and 2 extra search popups (see attached image)
Description: |
Screenshot of all parts of the interface |
|
Filesize: |
98.52 KB |
Viewed: |
2590 Time(s) |

|
|
|
Back to top |
|
 |
Shawn KiXforms Developer


Joined: 22 Feb 2003 Posts: 1983 Location: Canada
|
Posted: Thu Nov 15, 2007 4:03 pm Post subject: |
|
|
Wow - what a cool looking application. Are you using any DoEvent(0) method calls ?
-Shawn
|
|
Back to top |
|
 |
AJ83 KiXforms Follower

Joined: 14 Jun 2007 Posts: 16
|
Posted: Sun Nov 18, 2007 5:57 pm Post subject: |
|
|
Shawn wrote: | Wow - what a cool looking application. Are you using any DoEvent(0) method calls ?
-Shawn |
I don`t, should i?
Im not really up to speed regarding this command.
Could i use DoEvents(1) to make the application keep responding after starting a sql query? Now the application is unresponsive untill the result of the query is loaded into the listview.
Maybe the problem is just the fact i built a complicated application in a script language
|
|
Back to top |
|
 |
Sealeopard KiXforms Aficionado


Joined: 05 Mar 2003 Posts: 436 Location: Boston, MA
|
Posted: Mon Nov 19, 2007 1:31 am Post subject: |
|
|
The main problem is that the KiXtart script will not continue until the query is finished. One way to solve that would be to build something asynchronous, i.e. run the query in a separate KiXtart thread, then integrate the resultset back into the main script. doable, but complex.
_________________ Jens
'There are two kinds of vessels, submarines and targets.' |
|
Back to top |
|
 |
AJ83 KiXforms Follower

Joined: 14 Jun 2007 Posts: 16
|
Posted: Tue Dec 11, 2007 4:29 pm Post subject: |
|
|
The problem was indeed the $=Execute($MAIN_Form.DoEvents(0)) pretty stupid i didn`t notice b4.
How does using this make kix32.exe use so much cpu?
|
|
Back to top |
|
 |
Shawn KiXforms Developer


Joined: 22 Feb 2003 Posts: 1983 Location: Canada
|
Posted: Tue Dec 11, 2007 5:42 pm Post subject: |
|
|
Because DoEvents(0) returns immediately - even if there are no events in the event queue - basically its like an endless loop - what I usually do is put the following statement...
Sleep 0.100 ; msecs
...right after the DoEvents line inside the loop. Adjust the time up or down for best results. This frees-up your cpu and gives other processes a time-slice.
-Shawn
|
|
Back to top |
|
 |
|