to xeen 看一下我的处理行不行,下面是主要的代码,不知道是否达到你所说的
程序一运行就创建一个服务线程的效果
TSetControlThread = class (TThread)
protected
procedure Execute;override;
end;
var
hMutex:THandle;
myThread : TSetControlThread;
procedure TSetControlThread.Execute;
begin
mySetCOntrol:=TSetControl.Create(nil) ;
while not myThread.Terminateddo
begin
if WaitForSingleObject(hMutex,INFINITE)= wait_object_0 then
begin
if mySetCOntrol.GetQueueInfo then
begin
ReleaseMutex(hMutex);
mySetCOntrol.MatchingData(mySetControl.cdsInner.Data,mySetControl.CurMessage);
end
else
ReleaseMutex(hMutex);
end ;
end;
MySetControl.Free;
end;
initialization
TComponentFactory.Create(ComServer, TSetControl,
Class_SetControl, ciMultiInstance, tmApartment);
hMutex:=CreateMutex(nil,false,nil);
myThread:=TSetControlThread.Create(False);
finalization
myThread.Terminate;
Closehandle(hMutex);