我想为我的包装类实现自定义超时。
此代码正在运行但没有超时:/
让我们看看我实现了什么:
定义:
TComplusWrapper = class(TObject)
private
fComplus: OleVariant;
public
constructor Create;
destructor Destroy; override;
function Execute(paramOne: String; paramTwo: string): String;
end;
执行:
constructor TComplusWrapper.Create;
var
fMAchineName,
fApplication: string;
begin
fMAchineName := 'mydomain.com';
fApplication := '{83EAA392-6154-419B-9177-E0BB4C3F8785}';
fComplus := CreateRemoteComObject(FMachineName, StringToGUID(FApplication)) as IDispatch;
end;
destructor TComplusWrapper.Destroy;
begin
fComplus := VarNull;
end;
function TComplusWrapper.Execute(paramOne: string; paramTwo: string): string;
begin
//here I want to implement the timeout
Result := fComplus.fxExecute(paramOne, paramTwo);
end;
用过的:
procedure TMain.btnFakeClick(Sender: TObject);
var
complus: TComplusWrapper;
cXML,
fComputerName: string;
begin
cXML := '<exp>myXml</exp>';
fComputerName := 'LT-134242';
complus := TComplusWrapper.Create;
try
showMessage(complus.Execute( cXML, FComputerName))
finally
complus.Destroy;
end;
end;
我正在使用 Tokyo 10.2 并想在“TComplusWrapper.Execute”函数中编写自定义超时来监控,例如,如果需要太长时间,则强制结束“fComplus.fxExecute()”函数。有什么可能的想法吗?
提前致谢