midas线程中通过TSocketconnection.appserver调用服务端方法出现(EVariantInvalidArgError with mess

  • 主题发起人 主题发起人 libin202
  • 开始时间 开始时间
L

libin202

Unregistered / Unconfirmed
GUEST, unregistred user!
midas线程中通过TSocketconnection.appserver调用服务端方法出现(EVariantInvalidArgError with message 'Invalid argument'(200)<br />onstructor TCommThread.Create(CreateSuspended: Boolean);
begin
fTermIndex := 0;
ReadDataList := TStringList.create();
fThreadExit := false;
fsc:=TSocketConnection.Create(nil);
fsc.Host:=gServerip;
fsc.Port := gServerPort;
fSc.ServerGUID := '{0EC6940A-528D-406D-B958-1D8C9F9F59A2}';
fsc.Connected:=True;
fSc.Open;
//调用服务器方法SendStr := IrdmTSMainDisp(IDispatch(fsc.AppServer)).TermEvents('10101',3,3,'');//服务端方法在主窗体中调用可以,线程中调就报EVariantInvalidArgError with message 'Invalid argument'
 
我也遇到了线程中调用DCOM异常,未解决,帮顶。
 
来人呀急呀
 
知道了,同步就可以了
 
在线程中必须用同步。type TSockThread=class(TThread) private mySckconn :TSocketConnection;
serialID :string;
procedure addserialid;
protected procedure Execute;
override;
public constructor create(ip:string;port:Integer;serverName,serverguid:string);
destructor destroy;override;
end;
constructor TsockThread.create(ip:string;port:Integer;serverName,serverguid:string);
begin
inherited create(True);
//创建后不立即执行;而进行初始化变量。 serialID:='';
if mySckconn=nil then
mySckconn:=TSocketConnection.Create(nil);
mySckconn.Close;
mySckconn.Host:=ip;
mySckconn.Port:=port;
mySckconn.ServerGUID:=serverguid;
mySckconn.ServerName:=serverName;
mySckconn.Open;
Resume;
//待变量初始化完成后,再执行。end;
destructor Tsockthread.destroy;
begin
if mySckconn<>nil then
begin
mySckconn.Close;
FreeAndNil(mysckconn);
end;
end;
procedure Tsockthread.addserialid;
begin
if mySckconn.Connected then
begin
serialID:=mySckconn.AppServer.GetSerialID(1);
form1.Memo1.Lines.Add(serialID);
end;
end;
procedure TsockThread.Execute;
begin
if not Terminated then
begin
Synchronize(addserialid);
do
Terminate;
end;
end;
 
后退
顶部