Hello,
I'm using the TOraAlerter component and I'm getting access violations in the OnTimeout event handler when closing the application.
The effect can be reproduced with the Alerter demo application when the main thread is set to sleep for several seconds before the alerter is stopped. It seems to be a problem with the timing of the Windows messages. A OnTimeout event occurs after the alerter has been stopped, and the var parameter Continue refers to a variable that does not exist any more.
What can I do?
Best regards,
Walter Raaflaub
Access violation with TOraAlerter component
The problem can be reproduced when the following changes are made to the Alerter demo:
in Main.pas:
Clicking "Start" and then "Stop" on the right side reproduces the problem.
in Main.pas:
Code: Select all
procedure TfmMain.btStop2Click(Sender: TObject);
begin
if OraAlerter2.Active then begin
meLog2.Lines.Add('Setting main thread to sleep for 20s ...');
sleep(20000);
meLog2.Lines.Add('End sleep');
OraAlerter2.Stop;
meLog2.Lines.Add('Stoped');
end;
end;
...
procedure TfmMain.OraAlerter2TimeOut(Sender: TObject;
var Continue: Boolean);
begin
meLog2.Lines.Add('TimeOut, set Continue := False');
try
Continue := False;
except on e: Exception do
meLog2.Lines.Add(e.message);
end;
{$IFDEF MSWINDOWS}
MessageBeep(0);
{$ENDIF}
end;