Hi,friends
i want to use COM+ from a thread however it always reports error.The following is a delphi code snippet:
type
TAlarmReader = class(TThread)
public
procedure getData;
procedure execute; override;
end;
TfrmMain = class(TForm)
dcomAlarm: TDCOMConnection;
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
FAlarmReader : TAlarmReader;
public
{ Public declarations }
end;
var
frmMain: TfrmMain;
implementation
{$R *.DFM}
procedure TAlarmReader.getData;
begin
with frmMain.dcomAlarm do
try
Connected := True; <===== here will raise error
finally
Connected := False;
end;
end;
procedure TAlarmReader.execute;
begin
while (not Terminated) do begin
Synchronize(getData);
end;
end;
procedure TfrmMain.Button1Click(Sender: TObject);
begin
FAlarmReader := TAlarmReader.Create(True);
FAlarmReader.Priority := tpLower;
FAlarmReader.Resume;
end;
end.
the error message is strange !
Best Regards! IPO_z@cmmail.com
Garbage in,Garbage out
i want to use COM+ from a thread however it always reports error.The following is a delphi code snippet:
type
TAlarmReader = class(TThread)
public
procedure getData;
procedure execute; override;
end;
TfrmMain = class(TForm)
dcomAlarm: TDCOMConnection;
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
FAlarmReader : TAlarmReader;
public
{ Public declarations }
end;
var
frmMain: TfrmMain;
implementation
{$R *.DFM}
procedure TAlarmReader.getData;
begin
with frmMain.dcomAlarm do
try
Connected := True; <===== here will raise error
finally
Connected := False;
end;
end;
procedure TAlarmReader.execute;
begin
while (not Terminated) do begin
Synchronize(getData);
end;
end;
procedure TfrmMain.Button1Click(Sender: TObject);
begin
FAlarmReader := TAlarmReader.Create(True);
FAlarmReader.Priority := tpLower;
FAlarmReader.Resume;
end;
end.
the error message is strange !
Best Regards! IPO_z@cmmail.com
Garbage in,Garbage out