我的线程: type TSearChThread=class(TThread) private FCount:string; protected procedure Execute;override; public constructor Create(Const Senstr:string); end;procedure TSearChThread.ExeCute; begin FreeOnTerminate:=true; Synchronize(SearchFire(MainForm.IniXMLStr,FCount));//报错:There is no overloaded vision of 'Synchronize' that can be called with these argumentsend; constructor TSearChThread.Create(const SenStr:string); begin FCount:=SenStr; inherited Create(False); end; 其中 procedure SearchFire(XmlStr:String;SensorStr:string); var Leng:integer; DocDoM:IXMLDOMDocument; SearchRec:TSearchRec; begin if FindFirst(XMLStr,faAnyFile,SearchRec)=0 then begin CoInitializeEx (NIL,0); DocDoM:=CoDomDocument.Create; DocDom.load(MainForm.IniXMLStr); .... end; end;
例子如下:
procedure TMyThread.PushTheButton;begin
Button1.Click();
end;procedure TMyThread.Execute;
begin
...
Synchronize(PushTheButton);
...
end;
type
TSearChThread=class(TThread)
private
FCount:string;
protected
procedure Execute;override;
public
constructor Create(Const Senstr:string);
end;procedure TSearChThread.ExeCute;
begin
FreeOnTerminate:=true;
Synchronize(SearchFire(MainForm.IniXMLStr,FCount));//报错:There is no overloaded
vision of 'Synchronize' that can be called with these argumentsend;
constructor TSearChThread.Create(const SenStr:string);
begin
FCount:=SenStr;
inherited Create(False);
end;
其中
procedure SearchFire(XmlStr:String;SensorStr:string);
var
Leng:integer;
DocDoM:IXMLDOMDocument;
SearchRec:TSearchRec;
begin
if FindFirst(XMLStr,faAnyFile,SearchRec)=0 then
begin
CoInitializeEx (NIL,0);
DocDoM:=CoDomDocument.Create;
DocDom.load(MainForm.IniXMLStr);
....
end;
end;
Synchronize里是不允许操作过程和函数的。
可以照楼上的用事先定义线程数据的方法
处理比较好!