type
crm_base = class(TThread)
private
{ Private declarations }
taccountnumber: OleVariant;
INTEGRATIONID: OleVariant;
ScktConDB: tsocketconnection;
protected
procedure Execute; override;
procedure GETcurrent(a, b: string);
destructor Destroy; override;
end;
procedure crm_base.Execute;
var BATCH, batch1: variant;
begin
try
inherited;
CoInitialize(nil);
ScktConDB.AppServer.ESBCustomerInfo(INTEGRATIONID, taccountnumber, batch);
// center_10000.GetBaseInfo(batch); //基本信'' {Dcom.ScktConDB.AppServer.ESBOFFERS(INTEGRATIONID, batch1);
center_10000.GetSubProduct(batch1); //子产品
}
CoUnInitialize; //必须使用
Destroy;
except end;
end;procedure crm_base.GETcurrent(a, b: string);
begin
ScktConDB := tsocketconnection.Create(nil);
ScktConDB.Connected := false;
ScktConDB.Port := 212;
ScktConDB.ServerName := 'AppServer.RDM';
ScktConDB.Host := '127.0.0.1';
ScktConDB.Connected := true; taccountnumber := a;
INTEGRATIONID := b;
end;
以上是多线程类,我在系统里有一个socketconnection了,在这里又动态建立一个,但是不知道为什么总是报,invalid argument 错误,完后就关闭了连接,这到底是什么问题?
crm_base = class(TThread)
private
{ Private declarations }
taccountnumber: OleVariant;
INTEGRATIONID: OleVariant;
ScktConDB: tsocketconnection;
protected
procedure Execute; override;
procedure GETcurrent(a, b: string);
destructor Destroy; override;
end;
procedure crm_base.Execute;
var BATCH, batch1: variant;
begin
try
inherited;
CoInitialize(nil);
ScktConDB.AppServer.ESBCustomerInfo(INTEGRATIONID, taccountnumber, batch);
// center_10000.GetBaseInfo(batch); //基本信'' {Dcom.ScktConDB.AppServer.ESBOFFERS(INTEGRATIONID, batch1);
center_10000.GetSubProduct(batch1); //子产品
}
CoUnInitialize; //必须使用
Destroy;
except end;
end;procedure crm_base.GETcurrent(a, b: string);
begin
ScktConDB := tsocketconnection.Create(nil);
ScktConDB.Connected := false;
ScktConDB.Port := 212;
ScktConDB.ServerName := 'AppServer.RDM';
ScktConDB.Host := '127.0.0.1';
ScktConDB.Connected := true; taccountnumber := a;
INTEGRATIONID := b;
end;
以上是多线程类,我在系统里有一个socketconnection了,在这里又动态建立一个,但是不知道为什么总是报,invalid argument 错误,完后就关闭了连接,这到底是什么问题?
Execute过程中创建,而不能在Create中创建,因为Create中创建的对象是属于
主线程的,所以才会出现你说的那个错误。