在thread中调用AppServer上的过程可以吗?我的出错EvariantInvalidArgError(100分)

  • 主题发起人 主题发起人 hsgrass
  • 开始时间 开始时间
H

hsgrass

Unregistered / Unconfirmed
GUEST, unregistred user!
下面的代碼,在線程裏面執行時出錯,正常執行沒有問題,为什么?
1.EvariantInvalidArgError with message 'Invalid argument'
2.EsocketConnectionError with message 'error reading from socket'
type
ttest = class(tthread)
protected
frc: TDispatchConnection;
procedure execute;
override;
public
constructor Create(rc: TDispatchConnection);
destructor Destroy;
override;
end;

const
sql = 'select 1';
procedure TfAppMain.btn12Click(Sender: TObject);
var
t: ttest;
begin
cds1.Data := GetConnection.AppServer.GetDataSet(sql);
showmessage(inttostr(cds1.RecordCount));
t := ttest.Create(GetConnection);
end;

{ ttest }
constructor ttest.Create(rc: TDispatchConnection);
begin
CoInitialize(nil);
frc := rc;
FreeOnTerminate := true;
inherited create(false);
end;

destructor ttest.Destroy;
begin
CoUninitialize;
inherited;
end;

procedure ttest.execute;
begin
frc.AppServer.getdataset(sql);
end;
 
后退
顶部