I don't understand where I am going wrong, but I have the following code in
a windows app and a service. When I run the app in idle it uses 0% cpu, but
if I run the service it uses 50% of the CPU.
If I change the var activeport := false, (as to not receive serial data) the
service falls back to using 0% cpu.
Can someone advise what to do?
Why the difference between an app and a service?
-----------------------------------------
procedure TServerSerial.Execute;
begin
with Fser do
begin
IniFile :=
TIniFile.Create(ExtractFilePath(Application.ExeName)+'serialcollex.ini');
activeport := IniFile.Readbool('serial','active',false);
PortNo := IniFile.ReadString('serial','PortNo','COM1');
Baud := IniFile.Readinteger('serial','baud',9600);
databits := IniFile.ReadInteger('serial','databits',8);
stopbits := IniFile.ReadInteger('serial','stopbits',0);
par := IniFile.ReadString('serial','parity','N');
parity := par[1];
hardwarefl := IniFile.Readbool('serial','hardwarefl',false);
softwarefl := IniFile.Readbool('serial','softwarefl',false);
RaiseExcept:=false;
Connect(PortNo);
Config(Baud,databits,parity,stopbits ,softwarefl,hardwarefl);
if activeport = true then begin //Do we want to receive serial port
data.
repeat
if terminated then break;
if canread(1000) then
begin
LCMD := Recvstring(1000);
if lastError=0 then Synchronize(SendData);
end;
until false;
end;
end;
end;
----------------------------------------------
-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems? Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
synalist-public mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/synalist-public