Link to home
Start Free TrialLog in
Avatar of Yewsia
Yewsia

asked on

"raised exception class EThread" error box

Hi guys,
    I am doing a software on delphi, and I got this error message when I close my program.

error message:
project TTEST_1.exe raised exception class EThread
with message 'Thread Error: The handle is invalide(6)'.
Process stopped. Use Step or Run to continue.

I suspect that the following program code below is making the trouble.

program code:
procedure Ttest.FormShow(Sender: TObject);
begin
  try
    CommunicationPort.Open;
  except
    on e:ECommException do begin
      Application.ShowException( e );
      close;
    end;
  end;
end; // end of FormShow procedure.

I exit my program using the procedure I write below.

my exit program procedure:
procedure TXMKRAW.Close_Program();
begin
  CommunicationPort.Close;
  close;
end;
Avatar of mocarts
mocarts

before calling CommunicationPort.Close check wheteher it is opened.
something like:

procedure TXMKRAW.Close_Program();
begin
  if CommunicationPort.Active then // or .Connected
   CommunicationPort.Close;
  close;
end;
ASKER CERTIFIED SOLUTION
Avatar of WowPiangEh
WowPiangEh

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
btw, you can try running your exe file with your required database and ini file in a separate folder.