Login ProductsSalesSupportDownloadsAbout |
Home » Technical Support » DBISAM Technical Support » Support Forums » DBISAM General » View Thread |
Messages 1 to 5 of 5 total |
OT: How to idle properly |
Mon, Nov 20 2006 7:26 PM | Permanent Link |
Jim Margarit | I'm sending a command to a device over rs232 and waiting for the reply.
If I do... while length(replyString) < fixedReplyLen do application.processMessages; It uses up 90% of the cpu cycles. How should I be doing this to reduce the load? Thanks, Jim Margarit |
Mon, Nov 20 2006 7:34 PM | Permanent Link |
"Adam H." | Hi Jim,
> I'm sending a command to a device over rs232 and waiting for the reply. > If I do... > > while length(replyString) < fixedReplyLen do > application.processMessages; > > It uses up 90% of the cpu cycles. Not tested - but by placing a sleep command in the application - it should slow down the processing. ie: while length(replyString) < fixedReplyLen do begin application.processMessages; sleep(30); end; Best Regards Adam. |
Mon, Nov 20 2006 8:24 PM | Permanent Link |
"Malcolm" | Jim
I guess you are not using a serial comms component as it would provide you with the methods and events to do this without 'freezing' the system. If you are doing more than trivial communications I suggest you look at a component. There are several around, including free ones. I think the general idea is that you fire off your command, set a timeout (TTimer or built-in property) then forget it. Your component will fire an event when the full reply is received (assuming you can define this, STX/EOT) and if it proves to be a valid reply you stop the timer and process the message. If the timer fires you do whatever you need to do - like retries and error messages. Malcolm |
Tue, Nov 21 2006 4:30 AM | Permanent Link |
Roy Lambert NLH Associates Team Elevate | Jim
I'll go with Malcolm - and recommend Synapse Roy Lambert |
Tue, Nov 21 2006 10:03 AM | Permanent Link |
Jim Margarit | Hi,
Seems like I tried sleep the first time around with the same results but it has been a while. I'll try it again and see since it's such a simple replacement. Thanks Jim > Hi Jim, > >> I'm sending a command to a device over rs232 and waiting for the reply. >> If I do... >> >> while length(replyString) < fixedReplyLen do >> application.processMessages; >> >> It uses up 90% of the cpu cycles. > > Not tested - but by placing a sleep command in the application - it should > slow down the processing. ie: > > while length(replyString) < fixedReplyLen do > begin > application.processMessages; > sleep(30); > end; > > Best Regards > > Adam. > > |
This web page was last updated on Friday, April 19, 2024 at 07:09 AM | Privacy PolicySite Map © 2024 Elevate Software, Inc. All Rights Reserved Questions or comments ? E-mail us at info@elevatesoft.com |